Minimal nginx WebSocket reverse-proxy example
If you have a nginx
config clause like
example.txt
location /app/ {
proxy_pass http://app-server;
}
you can easily make it reverse-proxy Websocket connections as well by adding these clauses inside location { ... }
:
example.txt
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
Full example:
example.txt
location /app/ {
proxy_pass http://app-server;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
Check out similar posts by category:
Nginx
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow