nginx/0.8.54 - 502 Bad Gateway

António P. P. Almeida appa at perusio.net
Wed Jul 20 15:59:01 UTC 2011


On 20 Jul 2011 14h43 WEST, nginx-forum at nginx.us wrote:

> Hi,
>
> I'm running nginx as a reverse proxy for a jetty. I host a Liftweb
> App on localhost:8080. Nginx is listening on Port 81.
>
> Here is my nginx.conf:
>
> server {
> listen 81;
> server_name mysite.com www.mysite.com;
>
> location / {
> proxy_pass http://127.0.0.1:8080;
> proxy_set_header  X-Real-IP  $remote_addr;
> proxy_read_timeout 700;
> proxy_set_header Host $http_host;
> proxy_set_header X-Forwarded-For
> $proxy_add_x_forwarded_for;
> }
> }
>
> When I try to point my browser to mysite.com:81 I always get a 502
> Bad Gateway message. I checked the log and found this:

There's a problem in your upstream. Its refusing the connection? Do
you have some sort of access controls on it?

Try:

curl -I http://localhost:8080 and see if you can connect.

> connect() failed (111: Connection refused) while connecting to
> upstream, client: 12.34.567.890, server: mysite.com, request: "GET
> /favicon.ico HTTP/1.1", upstream:
> "http://127.0.0.1:8080/favicon.ico", host: "mysite.com:81"


> Does this means this port is blocked? I tried other but the result
> is still the same...
>
> My hosting company gave me the advice better not to use port 80 (i'm
> in china) and use some socket instead. I don't know what they mean
> by that.  I use port 81 for nginx now. Anyone an idea what they
> could mean by "use sockets"? I read somewhere that i can later
> forward all traffic from 81 to port 80.

If you want it to work transparently use port 80 for your frontend.

--- appa



More information about the nginx mailing list