http - nginx and proxying WebSockets -


i'm trying proxy websocket + http traffic nginx.

i have read this: http://nginx.org/en/docs/http/websocket.html

my config looks like:

http {     include       mime.types;     default_type  application/octet-stream;      sendfile        on;     keepalive_timeout  65;      gzip  on;      map $http_upgrade $connection_upgrade {       default upgrade;       ''      close;     }      server {       listen 80;       server_name ourapp.com;        location / {         proxy_pass http://127.0.0.1:100;         proxy_http_version 1.1;         proxy_redirect off;         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   upgrade          $http_upgrade;         proxy_set_header   connection       $connection_upgrade;       }     } } 

i have 2 problems:

1) connection closes once minute.

2) want run both http , ws on same port. application works fine locally, if try put http , ws on same port , set nginx proxy, this:

websocket connection 'ws://ourapp.com/ws' failed: unexpected response code: 200

loading app (http) seems work fine, websocket connection fails.

problem 1: connection dying once minute, realized it's nginx timeout variable. can either make our app ping once in while or increase timeout. i'm not sure if should set 0, decided ping once minute , set timeout 90 seconds. (keepalive_timeout)

problem 2: connectivity issues arose when used cloudflare cdn. disabling cloudflare acceleration solved problem.

alternatively create subdomain , set "unaccelerated" , use ws.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -