0
0
Nginxdevops~30 mins

Debug mode in Nginx - Mini Project: Build & Apply

Choose your learning style9 modes available
Enable and Test Debug Mode in Nginx
📖 Scenario: You are managing a web server using Nginx. Sometimes, errors happen and you want to see detailed logs to understand what went wrong. Enabling debug mode in Nginx helps you get detailed information about requests and errors.
🎯 Goal: Enable debug mode in the Nginx configuration and verify that debug logs are generated.
📋 What You'll Learn
Create a basic Nginx configuration file with a server block
Add a debug log level setting
Reload Nginx to apply the configuration
Check the error log output to confirm debug mode is active
💡 Why This Matters
🌍 Real World
Debug mode in Nginx helps system administrators and developers find detailed information about web server requests and errors, making troubleshooting easier.
💼 Career
Knowing how to enable and check debug logs in Nginx is a key skill for DevOps engineers and system administrators managing web servers.
Progress0 / 4 steps
1
Create a basic Nginx configuration file
Create a file called nginx.conf with a http block containing a server block that listens on port 8080 and serves requests with a root directory /usr/share/nginx/html.
Nginx
Need a hint?

Use http {} and inside it add server {} with listen 8080; and root /usr/share/nginx/html;.

2
Add debug log level to the error_log directive
Inside the http block in nginx.conf, add an error_log directive that writes to /var/log/nginx/error.log with the log level set to debug.
Nginx
Need a hint?

Place error_log /var/log/nginx/error.log debug; inside the http block but outside the server block.

3
Reload Nginx to apply the new configuration
Write the command to reload Nginx so it applies the new nginx.conf configuration without stopping the server. Use sudo.
Nginx
Need a hint?

Use sudo nginx -s reload to reload Nginx gracefully.

4
Check the error log for debug messages
Write the command to display the last 5 lines of the Nginx error log file /var/log/nginx/error.log to verify debug messages are present.
Nginx
Need a hint?

Use tail -n 5 /var/log/nginx/error.log to see recent log entries.