如何解决Nginx“proxy_pass 502 Bad Gateway”错误

我试图在我的nginx.conf文件中添加proxy_set_header.当我尝试添加proxy_pass并调用URL时,它会抛出502 Bad Gateway nginx / 1.11.1错误.

不确定如何解决此错误:

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;
}
最佳答案
如果你的Linux服务器使用的是SELINUX,那么你有可能想尝试这个问题.

setsebool -P httpd_can_network_connect true

请参阅Warren的回答:https://unix.stackexchange.com/questions/196907/proxy-nginx-shows-a-bad-gateway-error

转载注明原文:如何解决Nginx“proxy_pass 502 Bad Gateway”错误 - 代码日志