nginx 报错 upstream timed out (110: Connection timed out)解决方案 转

nginx 作PHP的web接口服务器。

在线上发现时不时经常崩溃。504,导致接口访问无响应回复。

查看日志:

[error] 11618#0: *324911 upstream timed out (110: Connection timed out) while reading response header from upstream, 
client:

然后百度看到都是修改nginx配置,解决超时问题

复制代码
large_client_header_buffers 4 16k;
client_max_body_size 30m;
client_body_buffer_size 128k;
#proxy_connect_timeout 300;
#proxy_read_timeout 300;
#proxy_send_timeout 300;
#proxy_buffer_size 64k;
#proxy_buffers   4 32k;
#proxy_busy_buffers_size 64k;
#proxy_temp_file_write_size 64k;

fastcgi_connect_timeout 300;
fastcgi_read_timeout 300;
fastcgi_send_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers   4 32k;
fastcgi_busy_buffers_size 64k;
fastcgi_temp_file_write_size 64k;
复制代码

根据自己服务器配置来选择以上配置。fastcgi 选择fastcgi。要放在server节内。

 

server {
listen 80;
server_name localhost;
autoindex on;
#charset koi8-r;

#access_log logs/host.access.log main;

location / {
root htdocs;
# include ../htdocs/nginx.htaccess;
index index.html index.php index.htm;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
include mysqladmin.conf;
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
fastcgi_connect_timeout 300;
fastcgi_read_timeout 300;
fastcgi_send_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 32k;
fastcgi_busy_buffers_size 64k;
fastcgi_temp_file_write_size 64k;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php(.*)$ {
root htdocs;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注