Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7436461
  • 博文数量: 1758
  • 博客积分: 18684
  • 博客等级: 上将
  • 技术积分: 16252
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-02 10:28
个人简介

啥也没写

文章分类

全部博文(1758)

文章存档

2024年(4)

2023年(44)

2022年(39)

2021年(46)

2020年(43)

2019年(27)

2018年(44)

2017年(50)

2016年(47)

2015年(15)

2014年(21)

2013年(43)

2012年(143)

2011年(228)

2010年(263)

2009年(384)

2008年(246)

2007年(30)

2006年(38)

2005年(2)

2004年(1)

分类: LINUX

2009-09-29 10:39:04

NGINX 502 Bad Gateway错误是FastCGI有问题,造成NGINX 502错误的可能性比较多。将网上找到的一些和502 Bad Gateway错误有关的问题和排查方法列一下,先从FastCGI配置入手:
1.查看FastCGI进程是否已经启动
NGINX 502错误的含义是sock、端口没被监听造成的。我们先检查fastcgi是否在运行
2.检查系统Fastcgi进程运行情况
除了第一种情况,fastcgi进程数不够用、php执行时间长、或者是php-cgi进程死掉也可能造成nginx的502错误
运行以下命令判断是否接近FastCGI进程,如果fastcgi进程数接近配置文件中设置的数值,表明worker进程数设置太少
netstat -anpo | grep "php-cgi" | wc -l
3.FastCGI执行时间过长
根据实际情况调高以下参数值
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
4.头部太大
nginx和apache一样,有前端缓冲限制,可以调整缓冲参数
fastcgi_buffer_size 32k;
fastcgi_buffers 8 32k;
如果你使用的是nginx的负载均衡Proxying,调整
proxy_buffer_size  16k;
proxy_buffers      4 16k;
5.https转发配置错误
正确的配置方法
server_name ;
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 ;
}
当然,还要看你后端用的是哪种类型的FastCGI,我用过的有php-fpm,流量约为单台机器40万PV(动态页面), 现在基本上没有碰到502。

 
阅读(1563) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2009-11-12 17:40:56

我真服了你了。。。。能不能告诉我这个普通人 ,我的电脑上不去网,的解决办法!!!看了你这个,真让人晕倒极点!!!FastCGI,php-fpm~~~这些个东西都是啥!!!!?????????哎u!!!急死我了