nginx + socket.io + proxy + ssl中的上游超时错误

时间:2015-04-10 21:55:27

标签: node.js ssl nginx socket.io reverse-proxy

我想我几乎没有想法。一直在尝试其他答案和所有博客上的所有解决方案,但仍然没有运气。

这就是我想要做的。我有nodejs服务器,socket.io在某个端口运行,并希望代理从端口80传递nginx。条件是我的应用程序仍然工作,并成功通过socket.io发送请求,另一个客户端收到它。但问题是我一直在“上游超时”错误,并且有很多错误。

这是我经过大量更改后的当前nginx设置:

upstream node_server.com {
  server 127.0.0.1:3002 max_fails=0 fail_timeout=10s;
  keepalive 512;
}

server {
  listen 443;

  client_max_body_size 16M;
  keepalive_timeout 10;

  ssl on;
  ssl_certificate my.crt;
  ssl_certificate_key my.key;
  ssl_session_timeout 5m;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
  ssl_prefer_server_ciphers on;

  server_name my_domain.com;


  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_buffers 8 32k;
    proxy_buffer_size 64k;

    proxy_pass https://node_server.com;
    proxy_redirect off;

    proxy_next_upstream error timeout http_500 http_502 http_503 http_504;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    tcp_nodelay on; # not necessary
  }
}

这是我收到的错误信息(其中有很多):

[error] 8131#0: *4599 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 112.215.64.131, server: my_domain.com, request: "GET /socket.io/?EIO=3&sid=ZRsV9eAnEItl90-vAH-j&transport=polling&user=2104655266f3db0f2a HTTP/1.1", upstream: "https://127.0.0.1:3002/socket.io/?EIO=3&sid=ZRsV9eAnEItl90-vAH-j&transport=polling&user=2104655266f3db0f2a", host: "my_domain.com"

即使我的应用程序现在仍然很难用,我想摆脱所有的错误。 非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

改变它

proxy_pass https://node_server.com;proxy_pass http://node_server.com;

你应该访问:

  

https://my_domain.com

`

希望它有所帮助!