0
0
Nginxdevops~10 mins

502 Bad Gateway troubleshooting 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 check if the Nginx service is running.

Nginx
systemctl [1] nginx
Drag options to blanks, or click blank then click option'
Astatus
Bstop
Cstart
Drestart
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' instead of 'status' will try to start the service instead of checking it.
2fill in blank
medium

Complete the code to test if the backend server is reachable on port 8080.

Nginx
curl -I http://localhost[1]
Drag options to blanks, or click blank then click option'
A:22
B:80
C:443
D:8080
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 80 tests the frontend, not the backend server.
3fill in blank
hard

Fix the error in the Nginx config to correctly proxy requests to the backend.

Nginx
location / {
    proxy_pass http://127.0.0.1:8080[1];
}
Drag options to blanks, or click blank then click option'
A:8080
B8080
C/
Dhttp://localhost:8080
Attempts:
3 left
💡 Hint
Common Mistakes
Using just ':8080' or '8080' without protocol causes config errors.
4fill in blank
hard

Fill both blanks to reload Nginx and check its error log for recent 502 errors.

Nginx
sudo systemctl [1] nginx && tail -n 20 /var/log/nginx/[2]
Drag options to blanks, or click blank then click option'
Areload
Bstart
Cerror.log
Daccess.log
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'start' instead of 'reload' restarts the service unnecessarily.
Checking 'access.log' won't show error details.
5fill in blank
hard

Fill all three blanks to create a dictionary of backend response times greater than 100ms from logs.

Nginx
response_times = { [1]: float(line.split()[2]) for line in logs if float(line.split()[2]) [2] [3] }
Drag options to blanks, or click blank then click option'
Aline.split()[0]
B>
C100
Dline.split()[1]
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong index for key or value.
Using '<' instead of '>' for filtering.