Minimales nginx WebSocket Reverse-Proxy-Beispiel
English
Deutsch
Wenn Sie eine nginx-Konfigurationsklausel wie
location_example.conf
location /app/ {
proxy_pass http://app-server;
}haben, können Sie leicht auch WebSocket-Verbindungen als Reverse-Proxy weiterleiten, indem Sie diese Klauseln innerhalb von location { ... } hinzufügen:
nginx_websocket_snippet.conf
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";Vollständiges Beispiel:
nginx_websocket_example.conf
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