当我尝试将nginx用作apache的reverce代理服务器时,我收到此错误。我想我的配置nginx方面有问题,因为当我使用apache访问带有端口的web主机时,一切都很好。 所以,这是我的主机的nginx配置文件:
server{
listen 80;
server_name my-site;
root /usr/share/nginx/www;
index index.html index.htm;
location /static {
alias /var/www/my-site/myapp/static;
}
location /media {
alias /var/www/my-site/myapp/media;
}
location / {
proxy_pass http://my-site:8000;
}
}
这是我的nginx错误日志,但对我来说没有任何用处:
2014/02/22 13:58:37 [error] 1398#0: *10 upstream timed out (110: Connection timed out) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: my-site, request: "GET / HTTP/1.1", upstream: "http://XXX.XXX.XXX.XXX:8000/", host: "my-site"
2014/02/22 14:01:40 [error] 1398#0: *14 upstream timed out (110: Connection timed out) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: my-site, request: "GET / HTTP/1.1", upstream: "http://XXX.XXX.XXX.XXX:8000/", host: "my-site"
2014/02/22 14:10:29 [error] 1609#0: *1 upstream timed out (110: Connection timed out) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: my-site, request: "GET / HTTP/1.1", upstream: "http://XXX.XXX.XXX.XXX:8000/", host: "my-site"
2014/02/22 19:07:59 [error] 647#0: *176 upstream timed out (110: Connection timed out) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: my-site, request: "GET / HTTP/1.1", upstream: "http://XXX.XXX.XXX.XXX:8000/", host: "my-site"
2014/02/23 13:40:35 [error] 647#0: *650 upstream timed out (110: Connection timed out) while connecting to upstream, client: XXX.XXX.XXX.XXX, server: my-site, request: "GET / HTTP/1.1", upstream: "http://XXX.XXX.XXX.XXX:8000/", host: "my-site"
我已经读到某个地方,当负载太大时可能会发生,但在我的情况下,这绝对不是它。
答案 0 :(得分:1)
您的Apache是否绑定到端口8000?
您是否确定可以使用与您的域相关联的外部IP地址访问端口8000?您可以通过检索服务器上带有http://my-site:8000
URL的页面来执行此操作。
您可以尝试使用
proxy_pass 127.0.0.1:8000;
而不是my-site:8000;
这样您就无需通过外部IP连接到您的网站了。