西数超哥博客
运维经验教程分享

upstream timed out (110: Connection timed out) while reading response header from upstream解决办法

通过nginx配置反向代理以后,很多时候会出现后端服务器超时的情况,前台一般看到的情况是504超时提示状态码。如果直接挂掉则会提示502.
这种情况原因比较多,比如后端服务器代码执行超时,或nginx代理端超时。默认30s,这里我们以nginx+fastcgi为例处理下:

upstream timed out (110: Connection timed out) while reading response header from upstream

解决办法:
当然这里只是服务器角度去做一点设置,归根还是要排查具体程序执行。
1,调整nginx站点配置。
我们添加如下代码:
proxy_read_timeout 300;
具体信息

        location ~ ^/(.*)\.php(/|$) {
            root /data/wwwroot/21yunwei;
             fastcgi_connect_timeout 900; 
             fastcgi_read_timeout 900; 
            fastcgi_send_timeout 900;
            fastcgi_pass   fastcgi;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
            fastcgi_param  HTTPS              off;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            if ( !-e $document_root$fastcgi_script_name) {
               return 404;
           }
        }

2,php设置时间过短,执行超时有可能会影响。
通过php –ini查看ini路径,修改php.ini重启对应服务。
调整max_execution_time = 300 ;

转载请注明:西数超哥博客www.ysidc.top» upstream timed out (110: Connection timed out) while reading response header from upstream解决办法

https://www.ysidc.top 西数超哥博客,数据库,西数超哥,虚拟主机,域名注册,域名,云服务器,云主机,云建站,ysidc.top

赞(0)
声明:本站发布的内容(图片、视频和文字)以原创、转载和分享网络内容为主,若涉及侵权请及时告知,将会在第一时间删除。本站原创内容未经允许不得转载:西数超哥博客 » upstream timed out (110: Connection timed out) while reading response header from upstream解决办法