nginx 499 502 413 404 处理

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改成一个时间

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)。

 

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;

}

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;
            }

aliyun活动 https://www.aliyun.com/acts/limit-buy?userCode=re2o7acl
原文地址:https://www.cnblogs.com/wangbin/p/1927696.html