0
0
Nginxdevops~10 mins

WebSocket proxying in Nginx - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to enable WebSocket proxying by setting the upgrade header.

Nginx
proxy_set_header Upgrade [1];
Drag options to blanks, or click blank then click option'
A"websocket"
B"upgrade"
C"WebSocket"
D"Upgrade"
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase 'WebSocket' instead of 'upgrade'.
Using 'Upgrade' or 'websocket' as the header value.
2fill in blank
medium

Complete the code to set the connection header for WebSocket proxying.

Nginx
proxy_set_header Connection [1];
Drag options to blanks, or click blank then click option'
A"keep-alive"
B"upgrade"
C"close"
D"Upgrade"
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'upgrade' instead of 'Upgrade'.
Using 'keep-alive' or 'close' which are incorrect for WebSocket.
3fill in blank
hard

Fix the error in the proxy_pass directive to correctly proxy WebSocket connections.

Nginx
proxy_pass http://[1];
Drag options to blanks, or click blank then click option'
Abackend_server:8080
Bbackend_server/ws
Cbackend_server:8080/ws
Dbackend_server
Attempts:
3 left
💡 Hint
Common Mistakes
Adding a URI path like '/ws' in proxy_pass causing incorrect routing.
Omitting the port when backend listens on a specific port.
4fill in blank
hard

Fill both blanks to correctly set headers for WebSocket proxying.

Nginx
proxy_set_header Upgrade [1];
proxy_set_header Connection [2];
Drag options to blanks, or click blank then click option'
A"WebSocket"
B"Upgrade"
C"upgrade"
D"Keep-Alive"
Attempts:
3 left
💡 Hint
Common Mistakes
Using uppercase or incorrect header values.
Mixing up the values between the two headers.
5fill in blank
hard

Fill all three blanks to complete the nginx location block for WebSocket proxying.

Nginx
location /ws/ {
    proxy_pass http://[1];
    proxy_http_version [2];
    proxy_set_header Upgrade [3];
}
Drag options to blanks, or click blank then click option'
Abackend_ws
B1.1
C"WebSocket"
D1.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using HTTP version 1.0 which does not support WebSocket.
Incorrect or missing quotes around header values.
Wrong backend server name.