nginx node.js代理502

时间:2017-12-25 01:33:14

标签: node.js nginx proxy

我在node.js后面的端口5000上运行了nginx服务器,在阅读了几篇帖子之后,我仍然从502获得了nginx。在浏览器中访问mydomain.com:5000时,一切正常。有人能发现我在这里做错了吗?

upstream backend {
    server localhost:5000 max_fails=1 fail_timeout=3s;
    keepalive 8;
}

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name mydomain.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name mydomain.com;
    ssl_certificate ssl/chained.crt;
    ssl_certificate_key ssl/server.key;

    location / {
        proxy_pass http://backend;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection '';
        proxy_set_header Host $host;
        proxy_set_header X-NginX-Proxy true;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_cache off;
        proxy_cache_bypass $http_upgrade;
    }
}

0 个答案:

没有答案