Nginx上游过早关闭连接,同时从上游形式Node js rocky proxy读取响应头

问题描述 投票:0回答:1

我有一个nginx和一个节点服务器,它作为java后端服务器之间的代理。我的nginx配置

server {
listen 80;

server_name peoplehum.dev www.peoplehum.dev;
#rewrite ^/(.*)/$ /$1 permanent;
charset utf-8;
keepalive_requests 100;
keepalive_timeout 100s;
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
client_max_body_size 16M;

#include /etc/nginx/proxy_header.conf;
#include /etc/nginx/proxy_buffer.conf;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
proxy_set_header HOST $host;

#X-Forwarded-Proto header gives the proxied server information about the schema of the original client request (whether it was an http or an https request).
proxy_set_header X-Forwarded-Proto $scheme;

#The X-Real-IP is set to the IP address of the client so that the proxy can correctly make decisions or log based on this information.
proxy_set_header X-Real-IP $remote_addr;

#The X-Forwarded-For header is a list containing the IP addresses of every server the client has been proxied through up to this point.
#In the example above, we set this to the $proxy_add_x_forwarded_for variable.
#This variable takes the value of the original X-Forwarded-For header retrieved from the client and adds the Nginx server's IP address to the end.
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

在这里,当我向nginx发送大体请求到我的节点代理服务器时,它会在从上游读取响应头时提供上游过早关闭的连接。

我在节点js上使用岩石代理 - > https://github.com/h2non/rocky代理。我已经搜索了很多,并尝试了大部分其他相关问题的答案,但没有成功。

node.js nginx proxy
1个回答
0
投票

经过这么多深入研究这个问题后,我得到了问题的根本原因。我正在使用这个函数here来装饰一些数据请求并且这样做我正在使用一个函数,它是异步调用Redis来获取一些数据而我希望它是同步这样做我使用这个包deasync。它适用于小文件或数据,但当涉及到更多数据或大文件时,它不知道它开始失败。

学习我的建议是使用本机承诺或使用任何其他包实际上建立在承诺或使用async await

© www.soinside.com 2019 - 2024. All rights reserved.