Step-by-step Guide: How to Enable the Nginx Status Page

watch 4m, 2s
views 2

14:08, 30.04.2025

Article Content
arrow

  • Activating the ngx_http_stub_status_module for NGINX
  • Setting Up the NGINX Status Dashboard
  • Establish the Default Server Configuration
  • Insert the stub_status Directive
  • Implement Access Controls for the NGINX Status Page
  • Apply Changes and Verify the Configuration
  • Viewing the NGINX Status Dashboard
  • Analyzing the NGINX Status Metrics
  • Connecting NGINX Status Data to Monitoring Systems
  • Using DataDog for NGINX Monitoring
  • General Uptime Monitoring Solution
  • Conclusion

The Nginx web server is renowned for its performance and scalability, making it a common choice for system administrators. One of its powerful features is the ability to enable a status page that provides real-time metrics about your server's health and performance. In this guide, we’ll walk you through the process of enabling the Nginx status page, configuring access, and integrating it with monitoring solutions.

But before we jump right into it, make sure that you have installed and configured NGINX.

Activating the ngx_http_stub_status_module for NGINX

Before viewing the Nginx status page, you need to make sure that ngx_http_stub_status_module is activated. Most Nginx distributions usually have it, but if you find that it’s not there, you should install a different version of Nginx that has the module.

To check if the module is included, execute the following command:

nginx -V 2>&1 | grep -o with-http_stub_status_module

If the output shows http_stub_status_module, this means that the module is included. If it doesn’t, consider installing the version of Nginx that has the mentioned module. Most package managers offer nginx-full package, which contains http_stub_status_module. Additionally, you can run the following command to install it:

apt-get install nginx-full

Setting Up the NGINX Status Dashboard

Now that we ensured that we have the module, let’s configure the status page. For this, open the Nginx configuration file (located at /etc/nginx/nginx.conf or /etc/nginx/conf.d/default.conf).

Establish the Default Server Configuration

Search the file for a default_server block. If you cannot find one, you’ll need to create one by inserting the following into the HTTP configuration block:

server { 
listen 80; 
listen [::]:80; 
server_name _; # catch-all domain 
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
    location = /404.html {
}
error_page 500 502 503 504 /50x.html;
    location = /50x.html {
}
}

Insert the stub_status Directive

Now, we have to define a location block for the stub_status module. The location block will help us determine an HTTP path for the status page.

Add the following location block in the default server block:

location /nginx/status { 
stub_status; 
}

Implement Access Controls for the NGINX Status Page

The status page requires access controls since it contains sensitive data that could potentially be used with malicious intent. You need to limit the IP addresses that can view the status page by adding allow/deny directives to the location block. You can do it by executing the following commands:

location /nginx/status { 
stub_status; 
allow 127.0.0.1; 
deny all; 
}

We recommend you allow internal networks to access the page by adding the line:  allow 10.0.0.0/8.

Apply Changes and Verify the Configuration

Next, let’s apply the changes and check the configuration. First, save your Nginx config file. Then test the configuration by running the following command:

nginx -t

Once the configuration is fully tested, restart the Nginx server to apply changes:

nginx -s reload

Viewing the NGINX Status Dashboard

There are several ways to view the Nginx status dashboard: through a web browser or a command line tool.

If you want to use a browser, open 127.0.0.1/nginx/status window.

If you want to use a command line tool like curl, run the following command:

curl http://127.0.0.1:80/nginx/status

Analyzing the NGINX Status Metrics

The NGINX status page provides several metrics, including:

  • Active connections: The number of currently active connections.
  • Accepted connections: The total number of connections accepted.
  • Handled connections: The total number of connections processed.
  • Requests: The total number of requests served.
  • Reading requests: The number of requests currently being read.
  • Writing responses: The number of responses presently being written.
  • Waiting for connection: The number of connections waiting for a response.
  • Reading from a file: The number of requests reading from a file.

Connecting NGINX Status Data to Monitoring Systems

It is important to connect Nginx status data to monitoring systems, and how you’re going to do that will depend on the system.

Using DataDog for NGINX Monitoring

To start using DataDog for Nginx monitoring, edit nginx.d/conf.yaml file, and set the nginx_status_url parameter to http://127.0.0.1:80/nginx/status.

All that is left to do is restart DataDog.

General Uptime Monitoring Solution

You can also use other monitoring solutions such as Prometheus, Grafana, or any uptime monitoring service that allows for HTTP checks. Simply point these tools to your Nginx status page URL.

Conclusion

Enabling the Nginx status page is a straightforward process that provides valuable insights into your server's performance. By following the steps outlined in this guide, you can effectively monitor your Nginx server, ensuring optimal performance and quick response to any potential issues. Integrating this data with monitoring solutions like DataDog enhances your ability to manage and maintain a healthy server environment.

Share

Was this article helpful to you?

VPS popular offers

Other articles on this topic

Linux OS Management Commands
Linux OS Management Commands
cookie

Accept cookies & privacy policy?

We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the HostZealot website.