enable status page in nginx

How To Enable NGINX Status Page

Last updated on September 20th, 2022 at 10:15 am

NGINX web server offers ngx_http_stub_status_module module that allows you to easily monitor server health. NGINX status page displays many useful server KPI metrics such as no. of active client connections, accepted, handled & total requests. It also shows reading, writing, and waiting connections. We will look at how to enable NGINX status page for your NGINX server.

How to Enable NGINX status page

Here are the steps to enable NGINX status page.

1. Check if NGINX status page is enabled

Most NGINX distributions come with ngx_http_stub_status_module module enabled. You can check if it is enabled in your NGINX installation using the following command

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

If you see –with-http_stub_status_module output, it means the status module is already enabled.

Otherwise you will need to compile NGINX from source along with status module. Here are the commands to compile NGINX with –with-http_stub_status_module

# wget http://nginx.org/download/nginx-1.13.12.tar.gz 
# tar xfz nginx-1.13.12.tar.gz 
# cd nginx-1.13.12/ 
# ./configure --with-http_stub_status_module 
# make 
# make install

Bonus Read : How to Install Varnish for NGINX

2. Enable status page

We will enable NGINX status page by setting up a URL (e.g /status_page) for status page. For this, add a location block in NGINX server configuration as shown below.

Open terminal and run the following command to open NGINX server configuration file.

$ sudo vi /etc/nginx/nginx.conf

If you have configured separate virtual hosts for your website (e.g www.example.com), such as /etc/nginx/sites-enabled/website.conf then open its configuration with the following command

$ sudo vi /etc/nginx/sites-enabled/website.conf

Add the following location block that will enable stub_status module

location /nginx_status { 
          allow; #only allow requests from localhost
          deny all; #deny all other hosts 

Replace above with your server’s IP address (e.g So your server block will look like

server {
      location /nginx_status {
        allow; #only allow requests from localhost
        deny all; #deny all other hosts

Bonus Read : Step by Step NGINX SSL configuration

3. Restart NGINX Server

Run the following command to check syntax of your updated config file.

$ sudo nginx -t

If there are no errors, run the following command to restart NGINX server.

$ sudo service nginx reload #debian/ubuntu
$ systemctl restart nginx #redhat/centos

Bonus Read : How to Prevent Image Hotlinking in NGINX

4. Test NGINX Status Page

Run the following command to visit your status page URL using curl command. Replace with your server IP or domain name

# curl 
# curl http://www.example.com/nginx_status

You will see a similar output with server metrics.

Hopefully the above tutorial will help you enable status page in NGINX. Please note ngx_http_stub_status_module module has been replaced by ngx_http_api_module module since Nginx 1.13.0 version.

Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it today!