【发布时间】:2020-05-07 22:31:53
【问题描述】:
给定一个超时为 10 秒的 NodeJS http 服务器:
const httpServer = require('http').createServer(app);
httpServer.timeout = 10 * 1000;
在超时时,邮递员会在没有任何响应代码的情况下显示此内容:
Error: socket hang up
Warning: This request did not get sent completely and might not have all the required system headers
如果 NodeJS 服务器位于 nginx 反向代理之后,则 nginx 返回 502 响应 (upstream prematurely closed connection while reading response header from upstream)。但这里只是在 localhost 上运行的 NodeJS/express。仍然有人期望得到正确的 http 响应。
根据this answer,这是预期的行为,套接字被简单地破坏了。
在带有 nginx 反向代理的架构中,服务器是否通常只销毁套接字而不向代理发送超时响应?
【问题讨论】:
标签: node.js express httpserver nginx-reverse-proxy