How to Enable NGINX Status Page


enable nginx status page

NGINX allows you to setup a basic status page that gives you useful information about your server such as no. of active connections, connections processed, no. of requests and waiting connections. This provides at-a-glance view of your server’s health. Here’s how to enable NGINX status page for your website.

 

How to Enable NGINX Status Page

Here are the steps to enable NGINX status page for your server. We will use the ngx_http_stub_status_module module for this purpose. By default, it is enabled on most linux distros.

 

1. Verify if ngx_http_stub_status_module is enabled

Open a terminal session, or SSH into your Linux system and run the command


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

You’ll see the following output


--with-http_stub_status_module

It means the status page module is enabled. Otherwise, you will need to compile NGINX from the source with –with-http_stub_status_module option as shown


# 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

 

2. Enable stub_status module

Open NGINX config file in a text editor


# sudo vim /etc/nginx/nginx.conf

 

Add the following block of code to set up status page at www.your_domain.com/nginx_status. Replace nginx_status with your required URL


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

Make sure you add the above location block inside the main server block, as shown below

Enable Nginx Status Page

 

Also replace 127.0.0.1 with your own IP so it is accessible only to you.

 

3. Test the configuration

Test the configuration


# nginx -t

You should see a message that ends with “…test is successful”

 

Reload NGINX to apply changes


# nginx -s reload

 

Visit NGINX status page on your web browser, or via curl command


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

 

The output will consist of key metrics about your server’s health.

 

That’s it! You have enabled NGINX status page for your website.

 

 

About Sreeram Sreenivasan

Sreeram Sreenivasan is the Founder of Ubiq, a business dashboard & reporting platform for small & medium businesses. Ubiq makes it easy to build business dashboards & reports for your business. Try it for free today!