小编the*_*art的帖子

nginx 是否允许上游服务器在请求完成之前响应并关闭请求?

我有一个 nginx 代理请求的图像上传服务。一切都很好。但有时,服务器已经拥有用户正在上传的图像。所以,我想早点回应并关闭连接。

在读取标头并与服务器核对后,我调用 Node 的response.end([data][, encoding][, callback])

Nginx barfs 并返回空白响应:

[error] 3831#0: *12879 readv() failed (104: Connection reset by peer) while reading upstream
Run Code Online (Sandbox Code Playgroud)

我的猜测是 nginx 假设上游服务器发生了一些不好的事情,立即断开客户端连接而不发送上游服务器的响应。

有谁知道当 nginx 是代理时如何正确响应和关闭客户端的连接?我知道这是可能的:请参阅:在请求进入之前发送响应

这是nginx conf文件:

worker_processes 8; # the number of processors
worker_rlimit_nofile 128; # each connection needs 2 file handles

events {
  worker_connections 128; # two connections per end-user connection (proxy)
  multi_accept on;
  use kqueue;
}

http {
  sendfile on;
  tcp_nopush on; # attempt to send HTTP response head …
Run Code Online (Sandbox Code Playgroud)

nginx streaming node.js

6
推荐指数
1
解决办法
2960
查看次数

标签 统计

nginx ×1

node.js ×1

streaming ×1