Nginx 502 Bad Gateway错误仅在Firefox中 [英] Nginx 502 Bad Gateway error ONLY in Firefox
问题描述
我在本地运行一个网站,所有流量都通过NGinx路由,然后将对PHP页面的请求分派到Apache并提供静态文件.在Chrome,Safari,IE等操作系统中完美运行.
I am running a website locally, all the traffic is routed through NGinx which then dispatches requests to PHP pages to Apache and serves static files. Works perfectly in Chrome, Safari, IE, etc.
但是,每当我在Firefox中打开网站时,都会出现以下错误:
However, whenever I open the website in Firefox I get the following error:
502 Bad Gateway
nginx/0.7.65
如果我清除缓存和cookie,然后重新启动FireFox,则能够在错误返回之前加载该站点一次或两次.我已经尝试了Firefox 3.6和Firefox 3.5,并且都遇到相同的问题.
If I clear out cache and cookies, and then restart FireFox, I am able to load the site once or twice before the error returns. I've tried both Firefox 3.6 and 3.5 and both have the same problem.
这是我的Nginx配置的样子:
Here is what my Nginx config looks like:
worker_processes 2;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name local.mysite.amc;
root /Users/joshmaker/Sites/mysite;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://local.mysite.amc:8080;
}
include /opt/local/etc/nginx/rewrite.txt;
}
server {
include /opt/local/etc/nginx/mime.types;
listen 80;
server_name local.static.mysite.amc;
root /Users/joshmaker/Sites/mysite;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}
}
这是Firefox在我的error.log文件中生成的错误:
And here is the errors that Firefox generates in my error.log file:
[error] 11013#0: *26 kevent() reported that connect() failed (61: Connection refused) while connecting to upstream
[error] 11013#0: *30 upstream sent too big header while reading response header from upstream
[error] 11013#0: *30 no live upstreams while connecting to upstream
我完全不知道为什么浏览器会导致服务器错误.有人可以帮忙吗?
I am completely at a loss why a browser would cause a server error. Can someone help?
推荐答案
我似乎找到了解决该问题的方法.在Google进行了一些其他研究之后,我在Nginx配置中添加了以下几行:
I seem to have found a work around that fixed my problem. After some additional Google research, I added the following lines to my Nginx config:
proxy_buffers 8 16k;
proxy_buffer_size 32k;
但是,我仍然不知道为什么为什么有效,以及为什么只有Firefox似乎有问题.如果有人可以阐明这一点,或提供更好的解决方案,将不胜感激!
However, I still don't know why this worked and why only Firefox seemed to have problems. If anyone can shed light on this, or offer a better solution, it would be much appreciated!
这篇关于Nginx 502 Bad Gateway错误仅在Firefox中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!