0
0
Nginxdevops~10 mins

Why Nginx handles API routing - Test Your Understanding

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

Complete the code to define the server listening on port 80.

Nginx
server {
    listen [1];
}
Drag options to blanks, or click blank then click option'
A80
B443
C8080
D22
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 443 without SSL configuration
Using port 22 which is for SSH
2fill in blank
medium

Complete the code to route API requests to the backend server.

Nginx
location /api/ {
    proxy_pass [1];
}
Drag options to blanks, or click blank then click option'
Ahttp://localhost:3000
Bhttps://example.com
Cftp://localhost
Dfile:///var/www
Attempts:
3 left
💡 Hint
Common Mistakes
Using HTTPS without backend support
Using file or FTP protocols incorrectly
3fill in blank
hard

Fix the error in the proxy header to pass the original host.

Nginx
location /api/ {
    proxy_set_header Host [1];
}
Drag options to blanks, or click blank then click option'
A$remote_addr
Blocalhost
C127.0.0.1
D$host
Attempts:
3 left
💡 Hint
Common Mistakes
Setting Host to localhost breaks backend routing
Using remote address instead of host
4fill in blank
hard

Complete the code to rewrite the API URL path correctly.

Nginx
location /api/ {
    proxy_pass http://backend[1]api;
}
Drag options to blanks, or click blank then click option'
A/
C/v1/
D/api/
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the trailing slash causes path concatenation errors
Adding extra /api/ duplicates the path
5fill in blank
hard

Fill all three blanks to add caching headers for API responses.

Nginx
location /api/ {
    proxy_pass http://backend/;
    add_header Cache-Control [1];
    add_header Pragma [2];
    add_header Expires [3];
}
Drag options to blanks, or click blank then click option'
A"no-cache"
B"no-store"
C"0"
D"max-age=3600"
Attempts:
3 left
💡 Hint
Common Mistakes
Using max-age enables caching which may cause stale data
Omitting headers leads to default caching behavior