NGINX Cookbook
上QQ阅读APP看书,第一时间看更新

How to do it...

We can enable the basic NGINX stub_status page to give some rudimentary statistics and service status. To enable, edit your site config and add the following:

location = /nginx_status { 
    stub_status on; 
    access_log   off; 
    allow <YOURIPADDRESS>; 
    deny all; 
} 

To prevent information leakage about your system, we have added the allow command. This should be your IP address. This is followed by the deny all command to prevent anyone else from loading the URL. We've also turned off access logs for this URL to save space.

After reloading your configuration (hint: systemctl reload nginx for systemd-based OS), you can now load the new URL /nginx_status in your browser.

You should see something like the following: