0
0
Nginxdevops~10 mins

Why advanced patterns solve complex requirements in Nginx - Test Your Understanding

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

Complete the code to set the server listening port to 8080.

Nginx
server {
    listen [1];
}
Drag options to blanks, or click blank then click option'
A80
B3000
C8080
D443
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 80 instead of 8080
Forgetting the semicolon
2fill in blank
medium

Complete the code to serve static files from the /var/www/html directory.

Nginx
server {
    root [1];
}
Drag options to blanks, or click blank then click option'
A/usr/share/nginx/html
B/home/user/html
C/etc/nginx/html
D/var/www/html
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong directory paths
Missing the semicolon
3fill in blank
hard

Fix the error in the location block to correctly match requests for /images/.

Nginx
location [1] {
    root /var/www/html;
}
Drag options to blanks, or click blank then click option'
Aimages/
B/images/
C/images
D/image/
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the trailing slash
Typo in the path
4fill in blank
hard

Fill both blanks to create a rewrite rule that redirects HTTP to HTTPS.

Nginx
server {
    listen 80;
    server_name example.com;
    return [1] https://[2]$request_uri;
}
Drag options to blanks, or click blank then click option'
A301
B302
Cexample.com
D$host
Attempts:
3 left
💡 Hint
Common Mistakes
Using 302 instead of 301
Hardcoding the domain name
5fill in blank
hard

Fill all three blanks to create a location block that proxies requests to a backend server.

Nginx
location [1] {
    proxy_pass [2];
    proxy_set_header [3] $host;
}
Drag options to blanks, or click blank then click option'
A/api/
Bhttp://backend:5000
CHost
D/static/
Attempts:
3 left
💡 Hint
Common Mistakes
Wrong location path
Incorrect proxy_pass URL
Missing or wrong header name