Minimal nginx WebSocket reverse-proxy example
If you have a nginx
config clause like
location /app/ {
proxy_pass http://app-server;
}
you can easily make it reverse-proxy Websocket connections as well by adding these clauses inside location { ... }
:
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
Full example:
location /app/ {
proxy_pass http://app-server;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}