Skip to content

Rage Against the Shell

Linux tips and other things…

  • Home
  • Contact
  • Privacy Policy

Day: April 30, 2016

Nginx status module

Posted on April 30, 2016 - September 25, 2016 by Mr. Reboot

Tested on Debian 7 / NGINX 1.10

You can watch the nginx connections stats compiling nginx with the option http_stub_status_module:

~ $ ./configure --sbin-path=/usr/local/sbin --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --with-http_ssl_module --with-http_addition_module --with-pcre-jit --with-http_stub_status_module

Make and install:

~ $ make && make install

Now add this to the section server in the vhost config:

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

Where x.x.x.x is your IP address. Also you can protect URL by http auth:

location /nginx_status {
                stub_status on;
                access_log off;
                auth_basic "Auth required";
                auth_basic_user_file /etc/nginx/htpasswd;
        }

Generate password file:

~ $ htpasswd -c /etc/nginx/htpasswd administrator
New password: 
Re-type new password: 
Adding password for user administrator
~ $ cat /etc/nginx/htpasswd
administrator:$apr1$kpTScFHe$A8W0.xtVq.gfiCY/9SdO71

Then reload nginx:

~ $ /etc/init.d/nginx reload

On load http://mydomain.com/nginx_status you will see:

Active connections: 2 
server accepts handled requests
 xxx yyy zzz 
Reading: 0 Writing: 2 Waiting: 0

Where:

mydomain.com: is your domain
xxx: total accepted connections
yyy: total handled connections
zzz: total handled requests

Posted in NginxLeave a comment

Search

Calendar

April 2016
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  
« Jan   May »

Categories

  • Apache
  • Cisco
  • Command line
  • Distros
  • Dovecot
  • File systems
  • Gadgets
  • GlusterFS
  • MySQL
  • Nginx
  • NTP
  • Opendkim
  • Pacemaker + Corosync
  • Postfix
  • Raspberrypi
  • SSH
  • SSL
  • Varnish

RSS RSS

  • Using qrencode January 16, 2022
  • Compile varnish module vmod_vsthrottle April 22, 2020
  • SSH vpn with sshuttle April 9, 2020
  • Disable swap in systemd December 16, 2019
  • Getting the parent process pid October 12, 2018
Proudly powered by WordPress | Theme: micro, developed by DevriX.