nginx中的配置如下:
server {
listen 80;
server_name www.test1.com;
location / {
proxy_pass http://test2.com/;
}
}
配置很简单,就是用nginx的proxy_pass来做转发。
但是却报502 Bad Gateway,查nginx的error log:
2018/09/12 11:10:14 [error] 2570#0: *5 recv() failed (104: Connection reset by peer) while reading response header from upstream
- 这个报错有点奇怪,我查了很久, recv() failed应该是php-fpm超时之类引起的报错。但是在这里只用nginx的proxy_pass,跟php-fpm之类没有什么关系。
nginx里的各种时间已经加长,不过都没什么用。
client_header_timeout 300s; 默认为60秒
client_body_timeout 300s; 默认为60秒
proxy_connect_timeout 300s; #连接超时 默认为60秒
proxy_read_timeout 300s; #读取超时 默认为60秒
proxy_send_timeout 300s; #发送超时 默认为60秒
- 另一个奇怪的问题,这是一台美国的服务器。
我用一台国内的服务器,用同样的配置的就是正常的。
大佬 解决了吗 我也遇到了这个问题 两台不同的服务器 一台可以成功一台失败