Challenge - 5 Problems
WebSocket Proxying Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediateWebSocket connection upgrade headers
You have an Nginx configuration proxying WebSocket traffic. What is the output of the following curl command headers when connecting to the WebSocket endpoint?
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" http://localhost/wsAttempts:
2 left
💡 Hint
WebSocket connections require HTTP 101 status with upgrade headers.
✗ Incorrect
When Nginx proxies WebSocket correctly, it responds with HTTP 101 Switching Protocols and includes Upgrade and Connection headers to establish the WebSocket connection.
❓ Configuration
intermediateCorrect Nginx config for WebSocket proxy
Which Nginx configuration snippet correctly enables WebSocket proxying to backend at ws://backend:8080/ws?
Attempts:
2 left
💡 Hint
The Upgrade header must use the client header variable, and Connection must be 'upgrade'.
✗ Incorrect
To proxy WebSocket, Nginx must forward the client's Upgrade header using $http_upgrade and set Connection to 'upgrade'. Other values break the WebSocket handshake.
❓ Troubleshoot
advancedWebSocket connection fails with 400 Bad Request
You configured Nginx to proxy WebSocket but clients get HTTP 400 Bad Request errors. Which is the most likely cause?
Attempts:
2 left
💡 Hint
WebSocket handshake requires specific headers to upgrade the connection.
✗ Incorrect
If Nginx does not forward the Upgrade and Connection headers correctly, the backend rejects the handshake causing 400 errors.
🔀 Workflow
advancedSteps to enable WebSocket proxying in Nginx
What is the correct order of steps to enable WebSocket proxying in Nginx?
Attempts:
2 left
💡 Hint
Headers must be set before proxy_pass, then reload Nginx.
✗ Incorrect
First set the headers to handle WebSocket upgrade, then proxy_pass to backend, finally reload Nginx to apply changes.
✅ Best Practice
expertBest practice for WebSocket timeout settings in Nginx
Which Nginx configuration snippet follows best practices to avoid WebSocket connection drops due to timeouts?
Attempts:
2 left
💡 Hint
WebSocket connections are long-lived and need longer timeouts.
✗ Incorrect
Setting long proxy_read_timeout and proxy_send_timeout prevents Nginx from closing idle WebSocket connections prematurely.
