Tips / Nginx

How to enable Nginx server status

Nginx provides us a good way to monitor the web server status using a module called stub_status_module. It is the same as “server-status” module used in the old Apache web server. With Nginx server status module you can gain useful information about your web server, such as:

  • Total requests
  • Requests per second
  • Number of connections
  • Number of reading, writing and waiting connections.

On most modern Nginx versions this status module comes already compiled, so you don’t need to do it manually. Anyway, you can check out if it is activated by running:

nginx -V

If you see “–with-http_stub_status_module”, then it’s ok. Once you ensure it’s activated, you can configure nginx status as you see below:

nano -w /etc/nginx/conf.d/status.conf

Place this code inside the serverĀ {} block

server {

    listen 80 default_server;
    access_log off;
    server_name _; 
    server_name_in_redirect off;
    root  /var/www/html;

        location /nginx_status {
        stub_status on;
        access_log   off;
        allow XX.XX.XX.XX;
        deny all;


Replace “/var/www/html” with the document root of your real server, and XX.XX.XX.XX with your real IP address (in case you need IP protection, otherwise you can delete the allow/deny lines to allow access from everywhere).

Save the file and then reload Nginx to apply changes:

service nginx reload

Testing Nginx server status module

curl http://XX.XX.XX.XX/nginx_status

You can also test this using your webserver using the same URL.

Nginx status monitor can work with graph tools such as Cacti or Rrdtool. On the next articles we will see how to integrate both things to have a better look of Nginx statistics.

Popular search terms:

  • nginx server status
  • nginx serve maintenance if no response from webserver
  • nginx server-status
  • enable stat nginx

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking

  • JesperA

    Great but is there a way that i could use this to output the stats in PHP so i can use it in my dashboard on my site?

  • Rash

    This is pretty cool. Thanks for sharing!

    Just a nitpick:

    service nginx restart

    and not reload.

    Oh btw, I didn’t know of this site, lots of cool stuff here!

    • Travis


      reload handles downtime free reloading of the server, while restart kills active connections, causing a noticeable outage.