Normally, there's an ad running in this spot, but you're using an ad blocker. To help support our blog, which provides free tutorials for everybody, we just ask that you whitelist or follow us on facebook, twitter, or subscribe using the form to the leftabove. Thank you!

    Enabling the NGiNX Status Page

    If you've ever been curious about monitoring your web servers in addition to what's provided in the logs, you can turn turn on the NGiNX status page with a few simple steps. This status page provides valuable information about server usage, which is explained in the NGiNX Http Status Module page. I've listed this information below, as well.

    • active connections -- number of all open connections including connections to backends
    • server accepts handled requests -- nginx accepted 16630948 connections, handled 16630948 connections (no one was closed just it was accepted), and handles 31070465 requests (1.8 requests per connection)
    • reading -- nginx reads request header
    • writing -- nginx reads request body, processes request, or writes response to a client
    • waiting -- keep-alive connections, actually it is active - (reading + writing)

    System requirements

    • A 32-bit or 64-bit computer with at least 8GB of RAM. 16GB or more is recommended.
    • At least 50GB of free disk space.

    Prerequisites

    1. Installing NGiNX

    Configuring NGiNX

    Installing NGiNX with apt-getbrew usually compiles it with the http stub status module. You can verify this by running the following command:

    nginx -V 2<&1 | sed 's,–,n–,g' | grep stub_status
    
    # look for this string in the output
    --with-http_stub_status_module 
    

    Now rather than add the /nginx_status location to each server block for all of our domains, we're just going to add a new server block in one location.

    # create a new status.conf
    sudo vi /etc/nginx/conf.d/status.conf
    
    # create a new status.conf
    sudo vi /usr/local/etc/nginx/conf.d/status.conf
    
    # with the following server block
    server {
      
      listen 80 default_server;
      access_log off;
      server_name _;
      server_name_in_redirect off;
    
      location /nginx_status {
        stub_status on;
    
        # Do not log access queries for status page
        access_log   off;
    
        allow 127.0.0.1;
        deny all;
      }
    } 
    

    Add as many allow IP.ADDRESS.GOES.HERE; lines to the location block for each user you want to give access. So for example, if you want to be able to view a live website's NGiNX status page from your work office, add an allow with your office's IP address.

    If NGiNX fails on restart, make sure to tail your /var/log/nginx/error.log. Also take note that this is where we want to indicate default_server, not under any *.com domain.

    Did you like this tutorial? Help us pay for server costs by following us on Facebook, Twitter, and subscribing below, where you'll get post notifications, training webinar invites, and free bundles.