Complete the code to check if the Nginx service is running.
systemctl [1] nginxThe systemctl status nginx command shows if the Nginx service is active and running.
Complete the code to test if the backend server is reachable on port 8080.
curl -I http://localhost[1]The backend server often listens on port 8080. Using curl -I http://localhost:8080 sends a HEAD request to check if it responds.
Fix the error in the Nginx config to correctly proxy requests to the backend.
location / {
proxy_pass http://127.0.0.1:8080[1];
}The proxy_pass directive requires the backend URL with a trailing slash if you want to pass the URI correctly. So http://127.0.0.1:8080/ is correct.
Fill both blanks to reload Nginx and check its error log for recent 502 errors.
sudo systemctl [1] nginx && tail -n 20 /var/log/nginx/[2]
Reloading Nginx applies config changes without downtime. Checking error.log shows recent errors like 502 Bad Gateway.
Fill all three blanks to create a dictionary of backend response times greater than 100ms from logs.
response_times = { [1]: float(line.split()[2]) for line in logs if float(line.split()[2]) [2] [3] }This comprehension extracts the first token as key and the third token as response time, filtering times greater than 100ms.