0
0
Nginxdevops~10 mins

Web server vs application server in Nginx - Interactive Practice

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

Complete the code to specify the port where Nginx listens for HTTP requests.

Nginx
server {
    listen [1];
    server_name localhost;
}
Drag options to blanks, or click blank then click option'
A22
B443
C80
D8080
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 443 for HTTP instead of HTTPS
Using SSH port 22 by mistake
2fill in blank
medium

Complete the code to forward requests to an application server running on port 3000.

Nginx
location /app/ {
    proxy_pass http://127.0.0.1:[1]/;
}
Drag options to blanks, or click blank then click option'
A80
B8080
C22
D3000
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 80 which is for web server
Using SSH port 22
3fill in blank
hard

Fix the error in the proxy_pass directive to correctly forward to the app server.

Nginx
location /api/ {
    proxy_pass http://127.0.0.1[1]3000/;
}
Drag options to blanks, or click blank then click option'
A:
B#
C;
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using slash '/' instead of colon
Missing colon causes syntax error
4fill in blank
hard

Complete the code to set up a reverse proxy with caching for the app server.

Nginx
location /service/ {
    proxy_pass http://127.0.0.1:3000/;
    proxy_cache [1];
}
Drag options to blanks, or click blank then click option'
A:
Bmy_cache
C/
Dcache_enabled
Attempts:
3 left
💡 Hint
Common Mistakes
Using '/' instead of ':' for port
Using undefined cache zone name
5fill in blank
hard

Fill both blanks to configure Nginx to serve static files and proxy API requests.

Nginx
server {
    listen 80;
    location /static/ {
        root [1];
    }
    location /api/ {
        proxy_pass http://127.0.0.1:3000/;
        proxy_set_header Host [2];
    }
}
Drag options to blanks, or click blank then click option'
A/var/www/html
B:
C$host
D/usr/local/nginx/html
Attempts:
3 left
💡 Hint
Common Mistakes
Wrong root path for static files
Missing colon before port
Incorrect Host header value