Nginx Status Explained
https://www.keycdn.com/support/nginx-status
Last updated
https://www.keycdn.com/support/nginx-status
Last updated
Updated on March 15, 2020
This article explains the process used to check the current status of your Nginx server as well as how to use the ngx_http_stub_status_module
to gain more insight about your web server. Having the information provided by the Nginx status page can be useful to help determine information pertaining to the number of requests your server is currently receiving, the amount of active connections, etc.
Checking the Nginx status on the command line shows if the web server is currently running. On any Debian/RHEL/Ubuntu/CentOS Linux the following command can be used (sudo
is not required if the user has root permissions):
If your Nginx server is currently running, the above command will return * nginx is running
and * nginx is not running
otherwise.
Similar commands can also be used to start, stop, or restart the server.
Nginx offers a convenient way to check the server status with the module ngx_http_stub_status_module
. With this module, you'll be able to view important information pertaining to your Nginx server on a status page.
Most modern versions of Nginx have this module already compiled, there is no need to compile it manually. You can check if the module is already compiled by using this command:
If -with-http_stub_status_module
appears within the configure arguments, then everything is working correctly. If you do not see this module upon running the above command, you may use the -with-http_stub_status_module
configuration parameter when building Nginx from source.
As a next step, the Nginx config needs to be prepared. Go to the folder where your Nginx config is located and open the file with an editor (e.g. VI).
The following code should go inside the server
block as shown.
The above code turns the status page on while also restricting access to it based on the defined allowed IP addresses. After the new config is saved, a reload of Nginx is required in order to get the Nginx status. Reload Nginx with the following command.
Once you have completed the above section, you now have access to view the Nginx status page. To view the status page you now have two options.
In a browser, navigate to your website URL /nginx_status
(e.g. https://www.example.com/nginx_status
)
Alternatively, you may use curl to retrieve the same information.
The output of Nginx status will look similar to this:
Explanation:
Active connections - Open connections in total. One user can have several concurrent connections to a server.
Three figures are shown:
All accepted connections.
All handled connections, which normally equals to the total number of accepted connections.
Total number of handled requests.
Reading: Nginx reads request headers
Writing: Nginx reads request bodies, processes requests, or writes responses to a client
Waiting: Keep-Alive
connections. This number depends on the keepalive_timeout
.
With this module, you can now better monitor your Nginx status to get a clearer picture of your server's connection/request stats.