top of page

Monitor Nginx Status

Enabling the NGINX status page involves configuring NGINX to expose a special endpoint that provides information about the server's current status, including active connections, requests, and more. Here are the steps to enable the nginx_status page:



1. Modify NGINX Configuration:


Open your NGINX configuration file. This file is typically located at /etc/nginx/nginx.conf or /etc/nginx/sites-available/default.


Add a location block inside the server block to enable the nginx_status page. Here's an example:

[root@siddhesh ~]# cat /etc/nginx/sites-available/default
server {
    listen 80;
    server_name localhost; # Change to your server's name or IP address

    location /nginx_status {
        stub_status on;
        access_log off;
        allow 127.0.0.1; # Allow access only from localhost
        deny all;
    }

    # Add the rest of your server configuration...
}
[root@siddhesh ~]#

In this example:


listen 80;: Defines the server to listen on port 80. Adjust if your NGINX server is running on a different port.

location /nginx_status { ... }: Configures the nginx_status location block.

stub_status on;: Enables the status page.

access_log off;: Disables access logging for the status page.

allow 127.0.0.1;: Allows access only from localhost. Adjust as needed.

deny all;: Denies access from all other IP addresses.


2. Restart NGINX:


After making changes to the configuration, restart NGINX to apply the changes:

[root@siddhesh ~]# systemctl restart nginx
[root@siddhesh ~]#

3. Access the Status Page:


Visit http://server_ip/nginx_status in your web browser, replacing server_ip with the actual IP address or domain name of your server.


nginx status

Where, Active connections: 2 clients are currently connected to the server.

Accepts: 30, the total number of accepted connections.

Handled: 30, the total number of handled connections.

Requests: 69, the total number of requests processed by the server.

Reading: 0 connections are currently reading a request.

Writing: 1 connection is currently writing a response.

Waiting: 1 connection is in a keep-alive state, waiting for additional requests.


By regularly monitoring the nginx_status page, administrators can gain insights into how NGINX is handling traffic, identify potential performance issues, and make informed decisions for optimization and troubleshooting.

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page