Skip to content

What is NGINX?

NGinx Logo

NGINX (pronounced “engine X”) is a popular HTTP server and reverse proxy server. As an HTTP server, NGINX serves static content very efficiently and reliably, using relatively little memory. As a reverse proxy, it can be used as a single, controlled point of access for multiple back-end servers or for additional applications such as caching and load balancing. NGINX is available both as a freea open-source product and in a more full-featured, commercially distributed version called NGINX Plus.

Supported versions

Open-source Nginx server are supported. Older server may not include all the metrics. NGinx plus is currently not supported as the output format differs from the open-source one.

Setup

Open-source NGINX exposes several basic metrics about server activity on a simple status page, provided that you have the HTTP stub status module enabled. To check if the module is already enabled, run:

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

The status module is enabled if you see with-http_stub_status_module as output in the terminal.

If that command returns no output, you will need to enable the status module. You can use the --with-http_stub_status_module configuration parameter when building NGINX from source:

./configure \ \
--with-http_stub_status_module
make
sudo make install

After verifying the module is enabled or enabling it yourself, you will also need to modify your NGINX configuration to set up a locally accessible URL (e.g., /nginx_status) for the status page:

server {
    location /nginx_status {
        stub_status on;

        access_log off;
        allow 127.0.0.1;
        deny all;
    }
}

Note: The server blocks of the NGINX config are usually found not in the master configuration file (e.g., /etc/nginx/nginx.conf) but in supplemental configuration files that are referenced by the master config. To find the relevant configuration files, first locate the master config by running:

nginx -t 

After changing any configurations, reload the configs by executing:

nginx -s reload

The status metrics page should be accessible and output something like:

Active connections: 38 
server accepts handled requests
 11446642 11446642 25972621 
Reading: 0 Writing: 2 Waiting: 36 

For testing purpose, you can use Nginx online demo status page.

Configuration

Nginx Wizard

The NGinx monitor requires the status page URL. Optional credentials can be provided when the status page is protected by basic authentication.

Counters

Nginx Counters Wizard

The NGinx monitoring module collects the following metrics:

  • Connections:

    • Active Connections: Current number of active connections,
    • Connection Accepts: Total number of accepted client connections,
    • Connection Successful: Total number of successful client connections,
    • Connection Requests: Total number of client connection requests,
    • Connection Accepts per sec: number of accepted client connections per second,
    • Connection Successful per sec: number of successful client connections per second,
    • Connection Requests per sec: number of client connection requests per second,
    • Connection Dropped per sec: number of client connection dropped (accepts - handled) per second.
  • Requests:

    • Waiting Requests: An active request may also be in a Waiting sub-state if there is no active request at the moment. New connections can bypass this state and move directly to Reading, most commonly when using accept filter or deferred accept, in which case NGINX does not receive notice of work until it has enough data to begin working on the response. Connections will also be in the Waiting state after sending a response if the connection is set to keep-alive,
    • Reading Requests: When a request is received, the connection moves out of the waiting state, and the request itself is counted as Reading. In this state NGINX is reading a client request header. Request headers are lightweight, so this is usually a fast operation,
    • Writing Requests: After the request is read, it is counted as Writing, and remains in that state until a response is returned to the client. That means that the request is Writing while NGINX is waiting for results from upstream systems (systems behind NGINX), and while NGINX is operating on the response. Requests will often spend the majority of their time in the Writing state.