9

I'm trying to proxy location to websocket upstream with nginx 1.9.11. Here's the config excerpt:

upstream autocloud_dispatcher {
  server 127.0.0.1:4000 fail_timeout=0;
}

server {
  .....
  location /ws {
    proxy_pass http://autocloud_dispatcher;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_connect_timeout 7d;
    proxy_send_timeout 7d;
    proxy_read_timeout 7d;
  }
}

Besides that I send ping messages from the backed every 90 seconds. But connection is still getting disconnected every 2 minutes. Some other setting in nginx that defaults to 120s?

1 Answer 1

9

Setting timeout in seconds helped me, my config

location ~ /wss/(.*) {
    proxy_pass http://127.0.0.1:$1;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $host;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;

    proxy_read_timeout  36000s;

    proxy_redirect off;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.