0
0
Nginxdevops~30 mins

Stub status module in Nginx - Mini Project: Build & Apply

Choose your learning style9 modes available
Monitor Nginx Server with Stub Status Module
📖 Scenario: You are managing a web server running Nginx. To keep track of how well your server is performing, you want to enable a simple status page that shows basic metrics like active connections and requests handled.This helps you quickly see if your server is busy or if there are any issues.
🎯 Goal: Enable and configure the Nginx stub_status module to create a status page accessible at /nginx_status. This page will show live server statistics.
📋 What You'll Learn
Create a new server block listening on port 8080
Add a location /nginx_status that uses the stub_status module
Allow access to the status page from localhost only
Test the configuration and display the status page output
💡 Why This Matters
🌍 Real World
Nginx stub_status is used by system administrators to quickly check server health and traffic without installing extra software.
💼 Career
Knowing how to enable and secure Nginx status pages is a common task for DevOps engineers and system administrators to monitor web servers.
Progress0 / 4 steps
1
Create a new server block listening on port 8080
Write a server block in Nginx configuration with listen 8080; and server_name localhost;.
Nginx
Need a hint?

Use server { ... } block with listen 8080; and server_name localhost;.

2
Add a location /nginx_status that uses the stub_status module
Inside the existing server block, add a location /nginx_status block with stub_status; directive.
Nginx
Need a hint?

Use location /nginx_status { stub_status; } inside the server block.

3
Allow access to the status page from localhost only
Inside the location /nginx_status block, add directives to allow access only from 127.0.0.1 and deny all others.
Nginx
Need a hint?

Use allow 127.0.0.1; and deny all; inside the location block.

4
Test the configuration and display the status page output
Run nginx -t to test the configuration, then reload Nginx. Finally, use curl http://127.0.0.1:8080/nginx_status to display the status page output.
Nginx
Need a hint?

Use nginx -t to test, nginx -s reload to reload, and curl http://127.0.0.1:8080/nginx_status to see the status.