求助~Node用Nginx进行反向代理在访问时间断式的返回502错误~大神帮忙看看~
发布于 7 年前 作者 linsicong003 5385 次浏览 来自 问答

运行环境是腾讯云WinServer2012+Node+Nginx 用来做微信小程序的环境

这是在nginx中报的错:

2017/08/29 11:45:43 [error] 2248#3984: *20560 WSARecv() failed (10054: An existing connection was forcibly closed by the remote host) while reading response header from upstream, client: 14.24.107.101, server: www.linsicong.cn, request: “POST /phonecall HTTP/1.1”, upstream: “http://127.0.0.1:3406/phonecall”, host: “www.linsicong.cn”, referrer: “https://servicewechat.com/wxddbff157dd6f59ce/0/page-frame.html

这是在nginx中的配置信息:

server { listen 80; server_name www.linsicong.cn linsicong.cn; proxy_buffer_size 64k; proxy_buffers 32 32k; proxy_busy_buffers_size 128k; rewrite ^(.*) https://$server_name$1 permanent;

} server { listen 443; server_name www.linsicong.cn linsicong.cn;

charset utf-8;
keepalive_requests 500;

proxy_http_version 1.1;

ssl on; 
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; 
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
ssl_certificate /nginxconf/1_www.linsicong.cn_bundle.crt;  
ssl_certificate_key /nginxconf/2_www.linsicong.cn.key; 

if ( $host != 'www.linsicong.cn' ){
	rewrite ^/(.*)$ https://www.linsicong.cn/$1 permanent;

}

**间隔一次的就弹出这个502提示了 :) ** 微信图片_20170829121351.png

给个url大神们可以体验一下 https://www.linsicong.cn/getdatelist

困扰了我好久的问题…各路大神给小弟指个明路呗 :)

2 回复

我也出现了这个问题,哪位大神指点一下啊!

亲测可行,附上多站点反向代理以及SSL证书部署。 upstream nodejs { server 127.0.0.1:8360; #你配置的端口 keepalive 64; } server { listen 80; server_name www.abc.com; #你的域名 access_log d:\var\www.abc.com.log; location / { 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_set_header Connection “”; proxy_pass http://nodejs; } } server { listen 443; server_name www.abc.com; access_log d:\var\www.abc.com.log; ssl on; ssl_certificate 214476802830976.pem;--------------------SSL证书 ssl_certificate_key 214476802830976.key; ssl_session_timeout 5m; ssl_protocols SSLv2 SSLv3 TLSv1; ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; ssl_prefer_server_ciphers on; location / { 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_set_header Connection “”; proxy_pass http://nodejs; } } upstream nodejs2 { server 127.0.0.1:8080; #你配置的端口 keepalive 64; } server { listen 80; server_name www.abc2.com; #你的域名 access_log d:\var\www.abc2.com.log; location / { 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_set_header Connection “”; proxy_pass http://nodejs2; } } server { listen 443; server_name www.abc2.com; access_log d:\var\www.abc2.com.log; ssl on; ssl_certificate 214224792290976.pem; ssl_certificate_key 214224792290976.key; ssl_session_timeout 5m; ssl_protocols SSLv2 SSLv3 TLSv1; ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; ssl_prefer_server_ciphers on; location / { 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_set_header Connection “”; proxy_pass http://nodejs2; } } 回到顶部

回到顶部