Nginx – WSS Reverse Proxy

Spread the love

Nginx – is a popular web server. One of the way of using it – is a reverse proxy. And in this article demonstrate, how to use it as the reverse proxy for WSS (WebSocket Secure). 

Need set  three important parameters for WSS:

  • proxy_http_version 1.1;
  • proxy_set_header Upgrade $http_upgrade;
  • proxy_set_header Connection “upgrade”;

The sample of part of configuration:

location / {
proxy_pass http://your_host:your_port/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

It was tested with ThingsBoard on the live update data dashboard. 

Leave a Reply