node.js应用程序与nginx 502错误的网关错误

我正在使用nginx配置我的node.js应用程序.它适用于http,但它不适用于https.当我尝试访问安全域时.我收到这个错误.

502 Bad Gateway
nginx/1.4.6 (Ubuntu)

这是我的nginx conf文件

    upstream node_app_dev {
        server 127.0.0.1:3000;
    }

    upstream node_app_production {
        server 127.0.0.1:3000;
    }

server {
    listen 80;
    server_name mydomain.com;
    access_log /var/log/nginx/dev.log;
    error_log /var/log/nginx/dev.error.log debug;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarder-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_pass http://node_app_dev;
        proxy_redirect off;
    }
}


server {
    listen 443 ssl;
    server_name mydomain.com;
    access_log /var/log/nginx/secure.log;
    error_log /var/log/nginx/secure.error.log debug;    

    ssl on;
    ssl_certificate certs/mycert.crt;
    ssl_certificate_key certs/mykey.key;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarder-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;        
        proxy_pass https://node_app_production;
        proxy_redirect off;

    }    
}
最佳答案
更换

proxy_pass https://node_app_production;

proxy_pass http://node_app_production;

重新启动nginx,你应该全部设置好.
nginx proxy pass Node, SSL?

转载注明原文:node.js应用程序与nginx 502错误的网关错误 - 代码日志