NGINX LAB

NGINX Plus のインストール

1. NGINX Plus、アドオンモジュールのインストール (15min)

こちらの手順「 NGINX Plusのインストール (15min)」を参考に、NGINX Plus、アドオンモジュールをインストールしてください

手順の内容に加えて、必要となるモジュールをインストールしてください

sudo apt-get install nginx-plus-module-njs

インストールしたパッケージの情報を確認いただけます

# dpkg-query -l | grep njs

ii  nginx-plus-module-njs              25+0.7.0-1~focal                      amd64        NGINX Plus njs dynamic modules

ラボの実施

1. 必要なパッケージの取得

sudo su
cd ~/
git clone https://github.com/BeF5/f5j-nginx-plus-lab2-security-conf.git

2. インストールしたNGINX Plusに必要な設定を追加

# sudo su
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf-bak
cat ~/f5j-nginx-plus-lab2-security-conf/base/loadmodules.conf /etc/nginx/nginx.conf-bak > /etc/nginx/nginx.conf

設定内容を確認します

head -7  /etc/nginx/nginx.conf
実行結果サンプル
1 # for NAP WAF
2 load_module modules/ngx_http_app_protect_module.so;
3 # for NAP DoS
4 load_module modules/ngx_http_app_protect_dos_module.so;
5 # for NJS
6 load_module modules/ngx_http_js_module.so;
7 load_module modules/ngx_stream_js_module.so;
  1. NGINX の起動

service nginx stop
service nginx start

対象となるプロセスが動作していることを確認します

ps -ef | grep -e nginx
実行結果サンプル
1 nginx       8408       1  0 08:18 ?        00:00:00 /bin/sh -c usr/share/ts/bin/bd-socket-plugin tmm_count 4 proc_cpuinfo_cpu_mhz 2000000 total_xml_memory 307200000 total_umu_max_size 3129344 sys_max_account_id 1024 no_static_config 2>&1 >> /var/log/app_protect/bd-socket-plugin.log
2 nginx       8410    8408  1 08:18 ?        00:00:01 usr/share/ts/bin/bd-socket-plugin tmm_count 4 proc_cpuinfo_cpu_mhz 2000000 total_xml_memory 307200000 total_umu_max_size 3129344 sys_max_account_id 1024 no_static_config
3 root        8452       1  0 08:18 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
4 nginx       8453    8452  0 08:18 ?        00:00:00 nginx: worker process
5 nginx       8454    8452  0 08:18 ?        00:00:00 nginx: worker process
6 root        8477    8366  0 08:21 pts/0    00:00:00 grep --color=auto -e nginx
  • 1-2行目 が NGINX App Protect WAFのプロセスです

  • 3行目 が NGINXのマスタープロセス、 4-5行目 がワーカープロセスです