Nginx php-fpm fast-cgi 502 Bad Gateway错误处理
Nginx php-fpm fast-cgi 502 Bad Gateway错误处理Nginx php-fpm fast-cgi 502 Bad Gateway不正确 是FastCGI有疑问 ,造成NGINX 502不正确 的可能性比较多。
将网上找到的一些和502 Bad Gateway不正确 有关的疑问 和排查要领 列一下,先从FastCGI配置入手:
1.FastCGI进程能不能 已经启动
2.FastCGI worker进程数能不能 不够
通过命令查看服务器上一共开了多少的 php-cgi 进程
ps -fe grep "php" grep -v "grep" wc -l
运用 如下命令查看已经有多少个php-cgi进程用来处理tcp请求
netstat -anop grep "php" grep -v "grep" wc -l
接近配置文件中配置 的数值,表明worker进程数配置 太少
参见:http://blog.s135.com/post/361.htm
3.FastCGI执行时间过长
根据实际情况调高以下参数值
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
4.FastCGI Buffer不够
nginx和apache一样,有前端缓冲限定 ,可以调整缓冲参数
fastcgi_buffer_size 32k;
fastcgi_buffers 8 32k;
参见:http://www.hiadmin.com/nginx-502-gateway-error%E4%B8%80%E4%BE%8B/
5.Proxy Buffer不够
如果你用了Proxying,调整
proxy_buffer_size16k;
proxy_buffers 4 16k;
参见:http://www.ruby-forum.com/topic/169040
6.https转发配置不正确
正确的配置要领
server_name www.mydomain.com;
location /myproj/repos {
set $fixed_destination $http_destination;
if ( $http_destination ~* ^https(.*)$ )
{
set $fixed_destination http$1;
}
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Destination $fixed_destination;
proxy_pass http://subversion_hosts;
页:
[1]