1.请检查你的FastCGI进程是否启动
2.FastCGI进程不够使用
请经过执行 netstat -anpo | grep "php-cgi" | wc -l 判断,是否接近你启动的FastCGI进程,接近你的设置,表示进程不够
来源:http://blog.s135.com/post/361.htm
3.执行超时
请把
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
这几项的值调高
来源:http://blog.s135.com/post/361.htm
4.FastCGI缓冲不够
nginx和apache同样,有前端缓冲限制
请把
fastcgi_buffer_size 32k;
fastcgi_buffers 8 32k;
这几项的值调高
来源:http://www.hiadmin.com/nginx-502-gateway-error一例/
5.Proxy缓冲不够
若是你使用了Proxying,请把
proxy_buffer_size 16k;
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;
}
来源:http://www.ruby-forum.com/topic/173455
7.php脚本执行时间过长
将php-fpm.conf的<value name="request_terminate_timeout">0s</value>的0s改为一个时间 php
8.Nginx 413错误的排查:修改上传文件大小限制
在上传时nginx返回了413错误,查看log文件,显示的错误信息是:”413 Request Entity Too Large”, 因而在网上找了下“nginx413错误”发现须要作如下设置:
在nginx.conf增长 client_max_body_size的相关设置, 这个值默认是1m,能够增长到8m以增长提升文件大小限制;
若是运行的是php,那么还要检查php.ini,这个大小client_max_body_size要和php.ini中的以下值的最大值一致或者稍大,这样就不会由于提交数据大小不一致出现的错误。
post_max_size = 8M
upload_max_filesize = 2M
9.Nginx 400错误排查:HTTP头/Cookie过大
今天有人汇报nginx的HTTP400错误,并且这个HTTP400错误并非每次都会出现的,查了一下发现nginx400错误是因为request header过大,一般是因为cookie中写入了较长的字符串所引发的。
解决方法是不要在cookie里记录过多数据,若是实在须要的话能够考虑调整在nginx.conf中的client_header_buffer_size(默认1k)
若cookie太大,可能还须要调整large_client_header_buffers(默认4k),该参数说明以下:
请求行若是超过buffer,就会报HTTP 414错误(URI Too Long)
nginx接受最长的HTTP头部大小必须比其中一个buffer大,不然就会报400的HTTP错误(Bad Request)。 html
10.参数都有所调整.目的是解决代理过程当中出现的一些502 499错误 前端
user www www;
worker_processes 4;
# [ debug | info | notice | warn | error | crit ]
error_log /usr/local/webserver/nginx/logs/nginx_error.log crit;
pid /usr/local/webserver/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
default_type application/octet-stream;
source_charset GB2312;
server_names_hash_bucket_size 256;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
#size limits
client_max_body_size 50m;
client_body_buffer_size 256k;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
#参数都有所调整.目的是解决代理过程当中出现的一些502 499错误
sendfile on;
tcp_nopush on;
keepalive_timeout 120; #参数加大,以解决作代理时502错误
tcp_nodelay on;
include vhosts/upstream.conf;
include vhosts/bbs.linuxtone.conf;
} node
server
{
listen 80;
server_name bbs.linuxtone.conf;
charset GB2312;
index index.html index.htm;
root /date/wwwroot/linuxtone/;
location ~ ^/NginxStatus/ {
stub_status on;
access_log off;
}
location / {
root /date/wwwroot/linuxtone/;
proxy_redirect off ;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 50m;
client_body_buffer_size 256k;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 60;
proxy_buffer_size 256k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
proxy_max_temp_file_size 128m;
proxy_pass http://bbs.linuxtone.com;
} linux