javascript – 502使用ExpressJS与nginx时网关不良

前端之家收集整理的这篇文章主要介绍了javascript – 502使用ExpressJS与nginx时网关不良前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

如果我运行我的expressjs应用程序,如:咖啡server.coffee和导航到本地主机:8080,一切都很好.

但是,当我用Nginx反向代理8080时,配置如下:

server {
    listen 0.0.0.0:80;
    server_name localhost;
    access_log /var/log/Nginx/nodetest.log;

    location / {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_set_header X-Nginx-Proxy true;

      proxy_pass http://node/;
      proxy_redirect off;
    }
}

upstream node {
    server 127.0.0.1:8080;
}

Chrome开发者控制台中出现以下错误

GET http://184.73.217.204/socket.io/xhr-polling//1300750540040 502(坏网关)

以及在Nginx的error.log中的以下内容

2011/03/22 13:07:59 [error] 10269#0: *18 upstream prematurely closed connection while
reading response header from upstream,client: 168.229.58.68,server: localhost,request:     "GET /socket.io/xhr-polling//1300799281533 HTTP/1.1",upstream:     
"http://127.0.0.1:8080/socket.io/xhr-polling/1300799281533",host: "184.73.217.204",referrer: "http://184.73.217.204/"

任何指导赞赏!

最佳答案
尝试这个补丁…

    -proxy_pass http://node/;
    +proxy_pass http://node;
原文链接:https://www.f2er.com/nginx/434641.html

猜你在找的Nginx相关文章