HowTo: Enable Nginx Status Page

Apache has status page that can provide data about Apache. How do I enable and display such page using nginx server? How do I enable nginx status page on Linux or Unix-like operating systems?

Like Aapache (httpd), nginx has status page to give you information about Nginx’s server health including Active connections and other data. You can use this info to fine tune your server. Please note that you will get stats for entire Nginx server running. This can not be used to get info per virtual host i.e. you will get data for entire Nginx server only.

Make sure HttpStubStatusModule compiled

Type the following command to verify that HttpStubStatusModule is compiled and available to you:
nginx -V | grep --color -o http_stub_status

Enable Nginx status page on Linux/Unix

Edit nginx.conf, enter:
# vi nginx.conf
Update your server { ..... } block/context as follows (see how to deny access to IP address on nginx):

   location /nginx_status {
        # Turn on nginx stats
        stub_status on;

        # I do not need logs for stats
        access_log   off;

        # Security: Only allow access from IP #
        # Send rest of the world to /dev/null #
        deny all;

Feel free to replace with your actual IP address. This is a security feature as you do not want to show your status to the whole world.

Restart / reload nginx server

Type the following command to reload nginx:
# service nginx reload
# nginx -s reload

How do I view nginx status page?

Fire a browser and type the url:

Sample outputs:

Gif 01: Nginx status page in action (note I am refreshing screen to show you demo)

Posted by: SXI ADMIN

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.


How to KVM, QEMU start or stop virtual machine from command line (CLI)

KVM or Kernel Based Virtual Machine is a popular virtualization technology. It allows you to run virtual guest machines over a host machine. To start...

How to Docker backup Saving and restoring your volumes

Running a Docker volume backup First, we spin up a temporary container, and we mount the backup folder and the target Docker volume to this container....

How to Start and Enable Firewalld on CentOS 7

In this article, we discuss how to start and enable firewalld. It is highly recommended that you have a firewall protecting your server.Pre-Flight CheckThese...