node.js - Nginx 使用 ng-flow 和 Express (Node.js) 挂起请求

标签 node.js express nginx flow-js ng-flow

我在使用 ng-flow、NodeJS 和 Express 进行开发时没有遇到任何问题,尽管我无法将 Nginx 正确配置为反向代理以使其与 ng-flow 和 Express 顺利运行。

您将在此处找到一个处于待处理状态的请求示例:

Remote Address:192.168.0.81:80
Request URL:http://itl.lan/api/v1/flow-upload/
Request Method:POST
Status Code:200 OK
Response Headers
view source
Cache-Control:private, no-cache, no-store, must-revalidate
Connection:close
Date:Mon, 03 Aug 2015 20:24:56 GMT
Expires:-1
Pragma:no-cache
X-Powered-By:Express
Request Headers
view source
Accept:*/*
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8,it;q=0.6
App-Session-Hash:df9b1ac0-3a10-11e5-af61-af8fb284004c
Connection:keep-alive
Content-Length:1049741
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryY2FVUSE0oIcye77i
Host:itl.lan
Origin:http://itl.lan
Referer:http://itl.lan/webapp/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.125 Safari/537.36
Request Payload
------WebKitFormBoundaryY2FVUSE0oIcye77i
Content-Disposition: form-data; name="flowChunkNumber"

9
------WebKitFormBoundaryY2FVUSE0oIcye77i
Content-Disposition: form-data; name="flowChunkSize"

1048576
------WebKitFormBoundaryY2FVUSE0oIcye77i
Content-Disposition: form-data; name="flowCurrentChunkSize"

1048576
------WebKitFormBoundaryY2FVUSE0oIcye77i
Content-Disposition: form-data; name="flowTotalSize"

12515925
------WebKitFormBoundaryY2FVUSE0oIcye77i
Content-Disposition: form-data; name="flowIdentifier"

12515925-showcase_001_20150802T2239tgz
------WebKitFormBoundaryY2FVUSE0oIcye77i
Content-Disposition: form-data; name="flowFilename"

showcase_0.0.1_20150802T2239.tgz
------WebKitFormBoundaryY2FVUSE0oIcye77i
Content-Disposition: form-data; name="flowRelativePath"

showcase_0.0.1_20150802T2239.tgz
------WebKitFormBoundaryY2FVUSE0oIcye77i
Content-Disposition: form-data; name="flowTotalChunks"

11
------WebKitFormBoundaryY2FVUSE0oIcye77i
Content-Disposition: form-data; name="file"; filename="showcase_0.0.1_20150802T2239.tgz"
Content-Type: application/x-compressed-tar

这是我在 NGINX server.conf 中的指令:

upstream itl_node_app {
    server 127.0.0.1:5000;
    keepalive 8;
}

server  {
...

    location /api/v1/flow-upload/ {
      proxy_set_header Access-Control-Allow-Origin *;
      proxy_set_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
      proxy_set_header 'Access-Control-Allow-Headers' 'X-Requested-With,Accept,Content-Type, Origin$

      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-NginX-Proxy true;
      proxy_pass http://itl_node_app;
      proxy_redirect off;
    }
}

检查 nginx error.log 你会发现:

2015/08/03 22:34:28 [error] 8004#0: *792 upstream sent no valid HTTP/1.0 header while reading response header from upstream, client: 192.168.0.4, server: itl.lan, request: "POST /api/v1/flow-upload/ HTTP/1.1", upstream: "http://127.0.0.1:5000/api/v1/flow-upload/", host: "itl.lan", referrer: "http://itl.lan/webapp/"

感谢任何帮助。

干杯, 卢卡

最佳答案

日志 NGINX 说 HTTP header 无效,请检查此路由中的express.js 上定义的 Controller :

/api/v1/flow-upload/

如果响应中发送的状态是数字。

希望这会有所帮助!

关于node.js - Nginx 使用 ng-flow 和 Express (Node.js) 挂起请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31796837/

相关文章:

nginx - 如何使用 nginx 以 https 模式运行 odoo?

javascript - 如何使用 webpack 保持我的 shebang 到位?

http - Nginx 正在运行但未提供服务

docker - NGINX反向代理不适用于Docker中运行的.NET Core WebAPI

node.js - ExpressJS - Sequelize - 查询结果未填充到对象中

javascript - 使用 next 传递响应正文

node.js - Mongoose 查询 where

node.js - 来自 post 请求的负载在 node.js 函数中不可用

javascript - 尝试在查询生成器中添加关联时无法读取未定义的属性 'source'。在 Sequelize ORM 中选择查询

css - PhantomJS:在呈现的 pdf 中忽略外部 CSS