How to configure the NGINX status page for monitoring NGINX performance

How to configure the NGINX status page for monitoring NGINX performance

The NGINX plugin uses the NGINX status page to pull the performance metrics of the NGINX server.

You may encounter the following errors while installing the NGINX plugin integration:
Error_code : HTTP Error 404: This error usually indicates that the server can't find the requested resource. It occurs when the NGINX plugin is unable to access the NGINX status page.
Error_code : URL Error [Errno 111] Connection refused: This error can occur when the plugin tries to access the NGINX status page but is unable to connect to the port. It likely means that the NGINX status module is not enabled or configured properly, or there might be an issue with the NGINX configuration.
HTTP Error 502: Bad Gateway and HTTP Error 503: This error is often an indication that NGINX is functioning as a reverse proxy or load balancer, and it forwards a request to the upstream server but receives an invalid response.

The errors mentioned above can be resolved by correctly enabling and configuring the NGINX status page for both the web server and load balancer. Here's a step-by-step approach to troubleshoot them.
  1. Ensure the stub status module (http_stub_status_module) is enabled
    Ensure that the NGINX status module, http_stub_status_module, is compiled with your NGINX installation. This module provides the necessary functionality to display the status page. If you are using a prebuilt NGINX package, it should usually be included by default. To confirm, check if the following line is present in your NGINX configuration:
    stub_status on;

  2. Check the NGINX configuration
    If the module is enabled, you should check your NGINX configuration file (located by default at /etc/nginx/nginx.conf or /etc/nginx/sites-available/default for most systems, or within a specific virtual host file).

    Here's a sample configuration that should allow access to the status page:

    server {
        listen 127.0.0.1:8080; # Adjust the IP and port if necessary
        server_name localhost; # You can use a different server_name if desired

        location /nginx_status {
            stub_status on;
            # Optionally restrict access to IP addresses if needed
            # allow 127.0.0.1;
            # deny all;
        }
    }

    In this configuration, the NGINX status page is available at http://localhost/nginx_status. If you have a different server_name or listen directive, or if the location path is different (like /status instead of /nginx_status), you should adjust your URL accordingly.

    For example, adjust the listen directive if you want to bind the status page to a specific IP address or port. By using 127.0.0.1, it will only be accessible from the local machine. 

  3. Test the status page configuration 
    After adding the status page configuration, run the following command to test the NGINX configuration for syntax errors:
    sudo nginx -t

  4. Reload NGINX
    If the test is successful, reload the NGINX service to apply the changes by running the following command:
    sudo systemctl reload nginx

  5. Access the NGINX status page
    When the NGINX server is running, you should be able to access the status page by visiting the following URL in your web browser:
    http://localhost:8080/nginx_status

    Replace localhost and 8080 with the appropriate server name and port if you've configured them differently.

    You can also test it with the following curl command:
    curl
    http://localhost/nginx_status

    The response of the command should be similar to the below output:
    Active connections: 2
    server accepts handled requests
    344014 344014 661581
    Reading: 0 Writing: 1 Waiting: 1

  6. Ensure the correct status page URL is used in the plugin .cfg file

    The NGINX plugin uses the status URL to pull the performance metrics of the NGINX server. By default, the plugin will have
    http://localhost/status/ as the configured status  page URL. 
    If this is different from the default URL, then update the URL accordingly in the nginx_status_url section of the .cfg file. Restart the agent after successfully updating.
Once the steps above are configured correctly, the plugin will automatically be added to your account within five minutes for you to view performance metrics in Site24x7.

If the issue persists, reach out to support@site24x7.com with the name of the plugin and the error.

Related documentation:

    • Related Articles

    • Troubleshoot the "ORA-12514" error when installing Oracle plugins

      When installing the Oracle database monitoring plugins, you may encounter the following error: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor: This error typically occurs during attempts to establish a ...
    • Troubleshoot "[Errno 111] Connection refused" error for RabbitMQ plugins

      When installing the RabbitMQ plugin, you may encounter the following error: urlopen error [Errno 111] Connection refused: This error usually occurs when the plugin tries to connect with the RabbitMQ server but is unable to establish a connection. ...
    • Troubleshoot the Error 404 and Error 99 for RabbitMQ

      When installing the RabbitMQ plugin, you may encounter the following errors: HTTP Error 404: Not Found: This error usually occurs when Site24x7's RabbitMQ monitoring plugin attempts to access the /api/overview page of RabbitMQ, but the resource ...
    • Configuring the status module (mod_status) for Apache monitoring

      The Apache mod_status module enables users to view detailed performance metrics of the Apache web server. You must enable and configure the mod_status correctly in the Apache configuration file to get performance metrics from Apache and view ...
    • Troubleshoot the HTTP Error 403 (Forbidden) for Jenkins

      When installing the Jenkins monitoring plugins, you may encounter the following error: HTTP Error 403: Forbidden: This error usually indicates that you don't have the necessary permissions to access a particular resource or perform a specific action ...