解决nginx 502 bad gateway--团队的力量
Posted siwnchs
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解决nginx 502 bad gateway--团队的力量相关的知识,希望对你有一定的参考价值。
我们是nginx反向代理
proxy是nginx作为client转发时使用的,如果header过大,超出了默认的1k,就会引发上述的upstream sent too big header (说白了就是nginx把外部请求给后端apache ,apache返回的header 太大nginx处理不过来就导致了。
server {
listen 80;
server_name *.xywy.com ;
large_client_header_buffers 4 16k;
#charset koi8-r;
# access_log off;
location / {
#添加这3行 ,
proxy_buffer_size 64k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 128k;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
set $baiduspider ‘‘;
if ( $http_user_agent ~ Baiduspider) {
set $baiduspider Baidu;
}
............
如果是 nginx+phpcgi 就该
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on
011/01/07 11:12:57 [error] 10770#0: *38585340 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 116.22.131.154, server: *.xywy.com, request: "GET /ysmp/index.php?did=124994 HTTP/1.0", upstream: "http://127.0.0.1:8080/ysmp/index.php?did=124994", host: "xywy.yn16.com"
后来原来那错误没了出了新错误了 upstream timed out 超时?
server {
listen 80;
server_name *.xywy.com ;
large_client_header_buffers 4 16k;
client_max_body_size 300m;
client_body_buffer_size 128k;
proxy_connect_timeout 600;
proxy_read_timeout 600;
proxy_send_timeout 600;
proxy_buffer_size 64k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
#charset koi8-r;
# access_log off;
后来参数我又改了下 就好了。。。
可以参考:
http://www.cnblogs.com/derekchen/archive/2011/02/21/1959626.html
http://wiki.nginx.org/NginxHttpProxyModule
http://blog.sina.com.cn/s/blog_5dc960cd0100i4mt.html
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!希望你也加入到我们人工智能的队伍中来!http://www.captainbed.net
以上是关于解决nginx 502 bad gateway--团队的力量的主要内容,如果未能解决你的问题,请参考以下文章
如何解决这个错误 Nginx and uwsgi 502 bad gateway