关于nginx proxy_pass的报错recv() failed

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
  1. 这个报错有点奇怪,我查了很久, 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秒
  1. 另一个奇怪的问题,这是一台美国的服务器。

我用一台国内的服务器,用同样的配置的就是正常的。

阅读 6.5k
2 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题