–with-http_stub_status_moduleg
があるか確認します。
$ nginx -V nginx version: nginx/1.18.0 (Ubuntu) built with OpenSSL 1.1.1f 31 Mar 2020 TLS SNI support enabled configure arguments: (略)--with-http_stub_status_module (略)
Nginxの設定フィアルに以下を書きます。
server { #Server Status location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; allow xx.xx.xx.xx; deny all; } }
curl -u http://xx.xx.xx.xx:yyyy/nginx_status curl -u user:password http://xx.xx.xx.xx:yyyy/nginx_status
$ curl -u user:password http://xx.xx.xx.xx:yyyy/nginx_status Active connections: 4 server accepts handled requests 10274 10274 30519 Reading: 0 Writing: 1 Waiting: 3
wget -q -O - http://xx.xx.xx.xx/nginx_status wget --http-user=xxxxx --http-passwd=xxxx -q -O - http://xx.xx.xx.xx:yyyy/nginx_status
$ wget --http-user=xxxx --http-passwd=xxxx -q -O - http://xx.xx.xx.xx:8888/nginx_status Active connections: 7 server accepts handled requests 10245 10245 30479 Reading: 0 Writing: 1 Waiting: 6