RewriteCond %{HTTP:Upgrade} websocket [NC] RewriteCond %{HTTP:Connection} upgrade [NC] RewriteRule /(.*) ws://localhost:8080/$1 [P,L] Use code with caution. Copied to clipboard ☁️ Cloud Providers & Load Balancers
Here are the most common solutions based on your infrastructure: 🚀 Nginx Configuration Fix proxy_set_header Upgrade $http_upgrade
Managed services often strip headers; ensure WebSocket support is enabled: : Enable Stickiness for polling fallbacks. Azure App Service : Toggle WebSockets on in configuration. 💻 Local Development Protocol : Ensure using ws:// or wss:// . proxy_set_header Connection "upgrade"
Ensure mod_proxy and mod_proxy_wstunnel are enabled. Use a RewriteRule in your VirtualHost to pass WebSocket traffic: proxy_set_header Upgrade $http_upgrade
location /ws { proxy_pass http://your_backend_server; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } Use code with caution. Copied to clipboard 🕸️ Apache Configuration Fix