相关疑难解决方法(0)

使用带有nginx的ExpressJS时出现502 Bad Gateway

如果我像这样运行我的expressjs应用程序:coffee server.coffee并导航到localhost: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;
}
Run Code Online (Sandbox Code Playgroud)

我在Chrome开发者控制台中收到以下错误:

GET http://184.73.217.204/socket.io/xhr-polling//1300750540040 502 (Bad Gateway)

以及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/"
Run Code Online (Sandbox Code Playgroud)

任何指导赞赏!

javascript nginx websocket express nowjs-sockets

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

express ×1

javascript ×1

nginx ×1

nowjs-sockets ×1

websocket ×1