1.Nginx 413错误的排查:修改上传文件大小限制
在使用上传POST一段数据时,被提示413 Request Entity Too Large,应该是nginx限制了上传数据的大小。 解决方法就是 打开nginx主配置文件nginx.conf,一般在/usr/local/nginx/conf/nginx.conf这个位置,找到http{}段,修改或者添加:client_max_body_size 2m;
如图:
然后重启nginx:
2.Proxy缓冲不够 如果你使用了Proxying,请把 proxy_buffer_size 16k; proxy_buffers 4 16k; 这几项的值调高 来源:http://www.ruby-forum.com/topic/169040
3. Nginx 400错误排查:HTTP头/Cookie过大 今天有人汇报 nginx 的HTTP400错误,而且这个HTTP400错误并不是每次都会出现的,查了一下发现 nginx 400错误是由于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)。
4.参数都有所调整.目的是解决代理过程中出现的一些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; }
5.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