Nginx post 请求正在等待 ng-flow 和 Express (Node.js)
Nginx post request pending with ng-flow and Express (Node.js)
我在使用 ng-flow、NodeJS 和 Express 进行开发时没有遇到任何问题,尽管我无法将 Nginx 正确配置为反向代理以使其 运行 顺利使用 ng-流量和快递。
您将在此处找到一个处于待处理状态的请求示例:
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 上定义的控制器:
/api/v1/flow-upload/
如果响应中发送的状态是一个数字。
希望对您有所帮助!
我写了 Express.js “/api/v1/flow-upload/” 路线作为模型并以 flow.js Node sample app, which you can find it here. The issue I described pops up on line 23 为例。 status 参数可能是字符串文字。我了解到 Nginx 管理它的方式比 Express 严格,引发了错误。
一个简单而安全的方法就是通过例如:
res.status(200).send();
我在使用 ng-flow、NodeJS 和 Express 进行开发时没有遇到任何问题,尽管我无法将 Nginx 正确配置为反向代理以使其 运行 顺利使用 ng-流量和快递。
您将在此处找到一个处于待处理状态的请求示例:
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 上定义的控制器:
/api/v1/flow-upload/
如果响应中发送的状态是一个数字。
希望对您有所帮助!
我写了 Express.js “/api/v1/flow-upload/” 路线作为模型并以 flow.js Node sample app, which you can find it here. The issue I described pops up on line 23 为例。 status 参数可能是字符串文字。我了解到 Nginx 管理它的方式比 Express 严格,引发了错误。
一个简单而安全的方法就是通过例如:
res.status(200).send();