Challenge - 5 Problems
WebSocket Proxying Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
WebSocket 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
intermediate2:00remaining
Correct 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
advanced2:00remaining
WebSocket 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
advanced2:00remaining
Steps 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
expert2:00remaining
Best 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.