NGINX不会将原始请求正文发送到上游节点应用程序

时间:2016-01-02 02:03:46

标签: node.js http nginx request http-post

所以我有一个Node应用程序来处理Nginx背后的身份验证。它安装在/ api / path上。当我发送POST请求(具有表单请求主体)时,Node应用程序不会收到请求正文。奇怪的是,Nginx似乎收到了请求正文,但它似乎并没有发送它。这是我的配置:

worker_processes 4;

events { worker_connections 1024; }

http {

log_format postdata $http_content_type $http_content_length $request_body;

upstream node-app {
      least_conn;
      server client1:8080 weight=10 max_fails=3 fail_timeout=30s;
      server client2:8080 weight=10 max_fails=3 fail_timeout=30s;
}

upstream api-gateway {
      least_conn;
      server gateway1:4747 weight=10 max_fails=3 fail_timeout=30s;
      server gateway2:4747 weight=10 max_fails=3 fail_timeout=30s;
}

server {
      listen 80;

      location / {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $http_host;
        proxy_cache_bypass $http_upgrade;

        proxy_pass http://node-app;
      }

      location /api/ {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_cache_bypass $http_upgrade;

        access_log /var/log/nginx/access.log postdata;
        proxy_pass http://api-gateway;
      }
}
}

我对Nginx很新,我通过Google,Stack Overflow和文档彻底搜索过。但是我觉得我错过了什么。有人可以帮忙吗?

0 个答案:

没有答案