How to resolve Nginx error "proxy_pass 502 Bad Gateway"

I am trying to add proxy_set_header to my nginx.conf file. When I try to add proxy_pass and call the url, it throws error 502 Bad Gateway nginx / 1.11.1.

Failed to resolve this error:

upstream app-server {
    # connect to this socket
    server unix:///tmp/alpasso-wsgi.sock;    # for a file socket
}

server {
    server_name <name>;

    listen 80 default_server;

    # Redirect http to https
    rewrite ^(.*) https://$host$1 permanent;
}

server {
    server_name <name>;

    listen 443 ssl default_server;

    recursive_error_pages on;

    location /azure{
        proxy_pass http://app-server;
    }

    ssl on;
    ssl_certificate      /etc/nginx/server.crt;
    ssl_certificate_key  /etc/nginx/server.key;
    ssl_client_certificate /etc/nginx/server.crt;
    ssl_verify_client optional;
}
+4
source share
3 answers

With a similar problem with proxy_pass, if your Linux server uses SELINUX, you can try this.

setsebool -P httpd_can_network_connect true

Pay attention to Warren's answer: https://unix.stackexchange.com/questions/196907/proxy-nginx-shows-a-bad-gateway-error

+4
source

Try:

location /azure {
    proxy_pass appserver;
}
0
source

502 , .

error log, failed to connect to upstream, , upstream, sudo service upstream status .

0

All Articles