node.js - nginx+socket.io+proxy+ssl 上游超时错误

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

我觉得我快没脑子了。一直在尝试其他答案和所有博文的所有解决方案,但仍然不走运。

这就是我想要做的。我有 nodejs 服务器,socket.io 在某个端口运行,并希望使用 nginx 从端口 80 传递代理。条件是我的应用程序仍然有效,并通过 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"

尽管我的应用程序现在仍然可以正常工作,但我想消除所有错误。 非常感谢任何帮助。

最佳答案

改变它

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

你应该访问:

https://my_domain.com

`

应该希望它有所帮助!

关于node.js - nginx+socket.io+proxy+ssl 上游超时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29571270/

相关文章:

javascript - 使用 Express 访问 Node.js 中的模型

javascript - 在 yaml 中的 gulp 任务中设置 --max_old_space_size

ssl - 有可能在一台计算机上合并 SSL 客户端和服务器吗?

ssl - 具有 OpenLDAP 和 SSL 的 WSO2 身份服务器

php - $_SERVER ['REMOTE_ADDR' ] 不适用于 php-fpm 和 nginx

nginx: [alert] kill(57200, 1) failed (3: No such process)

node.js - 如何解码快速 session cookie?

node.js - 如何在 React Native 中使用 Azure PubSub?

android - 如何使用 Retrofit 的输入流加载 SSL 证书

nginx - 如何在 nginx 中启用 CORS