P
P
Pavel2014-10-20 22:10:56
Nginx
Pavel, 2014-10-20 22:10:56

Why doesn't nginx forward the request when specifically specified to listen with a name and port?

server {
    listen crowd.***.com:80;
    server_name crowd.***.com;
    location / {
            proxy_pass http://localhost:8095;
            proxy_set_header    Host            $host;
            proxy_set_header    X-Real-IP       $remote_addr;
            proxy_set_header    X-Forwarded-for $remote_addr;
            port_in_redirect off;
            proxy_redirect   http://crowd.***.com/ /;
    }
}

Here is the configuration. In /etc/hosts, respectively, my external ip is registered, the dig crowd.***.com command returns my external ip in the A record. With this configuration, nginx shows me a welcome page, and if I write this configuration
server {
    listen 80;
    server_name crowd.***.com;
    location / {
            proxy_pass http://localhost:8095;
            proxy_set_header    Host            $host;
            proxy_set_header    X-Real-IP       $remote_addr;
            proxy_set_header    X-Forwarded-for $remote_addr;
            port_in_redirect off;
            proxy_redirect   http://crowd.***.com/ /;
    }
}

then when the crowd is off, it will show me 502 badgateway, which is what it should.
The question is, why does he not want to forward the request when specifying the address in listen?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question