文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>nginx 499 502 413 404 处理

nginx 499 502 413 404 处理

时间:2011-01-06  来源:Dufe王彬

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

相关阅读 更多 +
排行榜 更多 +
无限Fps

无限Fps

飞行射击 下载
幸存者时间僵尸

幸存者时间僵尸

飞行射击 下载
金属兄弟Metal Brother

金属兄弟Metal Brother

冒险解谜 下载