CentOS Stream 9 + Nginx + VTSモジュールをインストール
CentOS Stream 9上のNginxにVTSモジュールをインストールしたときの覚書。
環境: CentOS Stream 9, Nginx 1.20.1
1. VTSモジュールをインストール
今のNginxのビルドオプションを確認(改行して見やすく)。
# nginx -V 2>&1 | sed 's/ --/\n--/g'
nginx version: nginx/1.20.1built by gcc 11.5.0 20240719 (Red Hat 11.5.0-5) (GCC)built with OpenSSL 3.5.0 8 Apr 2025 (running with OpenSSL 3.5.1 1 Jul 2025)TLS SNI support enabledconfigure arguments:--prefix=/usr/share/nginx--sbin-path=/usr/sbin/nginx--modules-path=/usr/lib64/nginx/modules...
CentOS Streamではdnf経由でvtsモジュールをインストール。
# dnf search vts
# dnf install nginx-mod-vts
# dnf search vts
# dnf install nginx-mod-vts
modules-pathに配置されたか確認。
# ls /usr/lib64/nginx/modules
ngx_http_vhost_traffic_status_module.so
2.Nginxの設定
ダイナミックモジュールは自動で読み込むように設定してあった。
# less /etc/nginx/nginx.conf
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.include /usr/share/nginx/modules/*.conf;
# less /usr/share/nginx/modules/mod-vhost-traffic-status.conf
load_module "/usr/lib64/nginx/modules/ngx_http_vhost_traffic_status_module.so";
VTSの共有メモリゾーンを定義。
less /etc/nginx/nginx.conf
# serverディレクティブごとのトラフィック統計情報を保持する共有メモリゾーンを定義vhost_traffic_status_zone;
Basic認証とIP制限があるディレクティブにstatus表示用locationを定義。
# less /etc/nginx/conf.d/01_tools.conf
location /vts_status {vhost_traffic_status_display;vhost_traffic_status_display_format html;}
テストしてnginx再読み込み。
# nginx -t
# systemctl reload nginx
ブラウザで表示して確認する。