3

I think I almost out of idea. Been trying all solution on other answer and all blogpost, but still out of luck.

Here's what I'm trying to do. I have nodejs server with socket.io running in certain port and want proxy pass from the port 80 with the nginx. The condition is my app still work, and successfully sent the request via socket.io and the other client received it. But the thing is I keep getting "Upstream timed out" error, and there is a lot of them.

This is my current nginx setting after a lot changes:

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
  }
}

And this is the error message I got (there's a lot of them):

[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"

Even tough my app still work right now, I want to get rid all of the error. Really appreciate any help.

Gema Megantara
  • 520
  • 6
  • 15
  • FYI: I already try this solution http://stackoverflow.com/questions/10375659/nginx-proxy-pass-node-ssl?rq=1 and still no luck :( – Gema Megantara Apr 10 '15 at 22:14
  • Are you using Varnish by any chance? Also check [this issue](https://github.com/ether/etherpad-lite/issues/1230), your `proxy_redirect` could be overwritten somewhere in your config. – Tristan Foureur Apr 10 '15 at 23:14
  • I'm not using Varnish. And I already check using sudo grep -r proxy_redirect * in /etc directory, found proxy_redirect off that I used only – Gema Megantara Apr 11 '15 at 02:40
  • @GemaMegantara I'm seeing the same issue here, we're both using the same stack. I can't reproduce it in my lab/vagrant environment, only see it in production. Have you ever found a solution? – mark Sep 08 '15 at 13:31

1 Answers1

0

Change it

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

And you should access:

https://my_domain.com

`

Should hope it help !

Thanh Nguyen Van
  • 10,292
  • 6
  • 35
  • 53