CentOS 8のNginxでサーバステータスを確認する方法を設定してみました。
Apacheのmod_status的なものはNginxでは下記になるようです。
Module ngx_http_stub_status_module
http://nginx.org/en/docs/http/ngx_http_stub_status_module.html
--with-http_stub_status_module
が有効になっていれば利用できます。
環境
・CentOS Linux release 8.2.2004 (Core)
・Kernel 4.18.0-193.6.3.el8_2.x86_64
・nginx version: nginx/1.18.0(Nginx Repository)
- パラメータの確認
- 設定追加
- Reload
1 2 |
[root@centos8 ~]# nginx -V 2>&1 | grep -o with-http_stub_status_module with-http_stub_status_module |
with-http_stub_status_module
が表示されなかったら、どうする?
別ファイルを作成して設定してみます。
1 2 3 4 5 6 |
[root@centos8 ~]# vi /etc/nginx/default.d/nginx_status.conf location = /Nginx_status { stub_status; allow 192.168.1.0/24; deny all; } |
ちなみにバージョン1.7.5より以前のものと書き方が異なっています。
In versions prior to 1.7.5, the directive syntax required an arbitrary argument, for example, “stub_status on”.
1 2 3 4 |
[root@centos8 ~]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [root@centos8 ~]# systemctl reload nginx |
http://IP_Address/Nginx_status にアクセスするとステータスが確認できます。
Apache mod_statusと比べると取得項目は少なくちょっと物足りなく感じますね。