NGINX Plus の動作
1. NGINX Plusのインストール (15min)
Note
手順確認の目的で、NGINX Plusの他、NGINX App Protect WAF、NGINX App Protect Dosのインストール手順も示しています。 ただし、本ラボでセキュリティ機能の確認はありません
1. NGINX Licenseファイルのコピー
Note
取得したライセンスファイルをJump Host
にコピーした後、ubuntu-01
に送信するためにpscp
をご利用いただくことが可能です。以下コマンドを参考にご利用ください。コマンドプロンプト、powershellなどのターミナルから実行いただけます
コマンド: pscp -i <SSHで利用する公開鍵> <送付するファイル> <宛先>
pscp -i .\.ssh\id_rsa-putty.ppk <送信するファイル> ubuntu@10.1.1.7:/home/ubuntu
sudo mkdir -p /etc/ssl/nginx
sudo cp ~/nginx-repo.crt /etc/ssl/nginx/
sudo cp ~/nginx-repo.key /etc/ssl/nginx/
2. コマンドの実行
NGINX、App Protect WAF と App Protect DoS のリポジトリに利用する鍵を取得します
sudo wget https://cs.nginx.com/static/keys/nginx_signing.key && sudo apt-key add nginx_signing.key
sudo wget https://cs.nginx.com/static/keys/app-protect-security-updates.key && sudo apt-key add app-protect-security-updates.key
必要となるパッケージをインストールします
sudo apt-get install -y apt-transport-https lsb-release ca-certificates wget
レポジトリの情報を追加します
# NGINX Plusのレポジトリ情報
printf "deb https://pkgs.nginx.com/plus/ubuntu `lsb_release -cs` nginx-plus\n" | sudo tee /etc/apt/sources.list.d/nginx-plus.list
# NGINX App Protectのレポジトリ情報
printf "deb https://pkgs.nginx.com/app-protect/ubuntu `lsb_release -cs` nginx-plus\n" | sudo tee /etc/apt/sources.list.d/nginx-app-protect.list
printf "deb https://pkgs.nginx.com/app-protect-security-updates/ubuntu `lsb_release -cs` nginx-plus\n" | sudo tee -a /etc/apt/sources.list.d/nginx-app-protect.list
# NGINX App Protect DoSのレポジトリ情報
printf "deb https://pkgs.nginx.com/app-protect-dos/ubuntu `lsb_release -cs` nginx-plus\n" | sudo tee /etc/apt/sources.list.d/nginx-app-protect-dos.list
aptコマンドの設定情報を取得します
sudo wget -P /etc/apt/apt.conf.d https://cs.nginx.com/static/files/90pkgs-nginx
パッケージ情報を更新します
sudo apt-get update
3. NGINX パッケージのインストール
sudo apt-get install -y nginx-plus
sudo apt-get install -y app-protect app-protect-attack-signatures
sudo apt-get install -y app-protect-dos
# NAP DoS Release 3.0 より
sudo apt-get install -y app-protect-dos app-protect-dos-ebpf
インストールしたパッケージの情報の確認します
nginx -v
NGINX App Protect のVersion
cat /opt/app_protect/VERSION
NGINX App Protect DoS のVersion
admd -v
その他インストールしたパッケージの情報を確認いただけます。ラボ環境のホストはUbuntuとなります。
1 2 3 4 | # dpkg-query -l | grep nginx-plus ii nginx-plus 25-1~focal amd64 NGINX Plus, provided by Nginx, Inc. ii nginx-plus-module-appprotect 25+3.671.0-1~focal amd64 NGINX Plus app protect dynamic module version 3.671.0 ii nginx-plus-module-appprotectdos 25+2.0.1-1~focal amd64 NGINX Plus appprotectdos dynamic module |
1 2 3 4 5 6 7 8 9 10 | # dpkg-query -l | grep app-protect ii app-protect 28+4.2.0-1~focal amd64 App-Protect package for Nginx Plus, Includes all of the default files and examples. Nginx App Protect provides web application firewall (WAF) security protection for your web applications, including OWASP Top 10 attacks. ii app-protect-attack-signatures 2023.01.09-1~focal amd64 Attack Signature Updates for App-Protect ii app-protect-common 10.179.0-1~focal amd64 NGINX App Protect ii app-protect-compiler 10.179.0-1~focal amd64 Control-plane(aka CP) for waf-general debian ii app-protect-dos 28+3.1.7-1~focal amd64 Nginx DoS protection ii app-protect-dos-ebpf 28+3.1.7-1~focal amd64 Nginx DoS protection ii app-protect-engine 10.179.0-1~focal amd64 NGINX App Protect ii app-protect-plugin 4.2.0-1~focal amd64 NGINX App Protect plugin ii app-protect-threat-campaigns 2023.01.11-1~focal amd64 Threat Campaign Updates for App-Protect |
2. NGINXの基礎
1. ステータスの確認 (5min)
NGINX Plusのアーキテクチャ
NGINX の停止・起動
sudo service nginx stop
sudo service nginx start
NGINX のstatusを確認します
sudo service nginx status
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ● nginx.service - NGINX Plus - high performance web server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2021-11-22 10:12:55 UTC; 11s ago Docs: https://www.nginx.com/resources/ Process: 9126 ExecStartPre=/usr/lib/nginx-plus/check-subscription (code=exited, status=0/SUCCESS) Process: 9146 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS) Main PID: 9147 (nginx) Tasks: 3 (limit: 2327) Memory: 2.6M CGroup: /system.slice/nginx.service ├─9147 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf ├─9148 nginx: worker process └─9149 nginx: worker process Nov 22 10:12:55 ip-10-1-1-7 systemd[1]: Starting NGINX Plus - high performance web server... Nov 22 10:12:55 ip-10-1-1-7 systemd[1]: nginx.service: Can't open PID file /run/nginx.pid (yet?) after start: Operation not permitted Nov 22 10:12:55 ip-10-1-1-7 systemd[1]: Started NGINX Plus - high performance web server. |
pidファイルの配置場所の確認します
grep pid /etc/nginx/nginx.conf
1 | pid /var/run/nginx.pid; |
pidの内容を確認します
cat /var/run/nginx.pid
1 | 9147 |
論理コア数を確認します
grep processor /proc/cpuinfo | wc -l
1 | 2 |
NGINX Processを確認します
NGINXはMaster Processと通信制御を行うWorker Processに分かます。Worker ProcessはCPUCore数の数起動し、並列処理を行う設定となっている。 Master ProcessのPIDがPIDファイルに記載されている内容と一致していることを確認する また、Worker ProcessがCPU Core数の数だけ起動していることを確認します
ps aux | grep nginx
1 2 3 4 5 6 7 | nginx 9122 0.0 0.0 2616 608 ? Ss 10:12 0: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 nginx 9123 0.3 3.0 385260 61592 ? Sl 10:12 0:00 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 nginx 9125 0.0 0.0 2616 608 ? Ss 10:12 0:00 /bin/sh -c /usr/bin/admd -d --log info 2>&1 > /var/log/adm/admd.log nginx 9127 0.5 2.5 799208 50732 ? Sl 10:12 0:00 /usr/bin/admd -d --log info root 9147 0.0 0.0 9136 892 ? Ss 10:12 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf nginx 9148 0.0 0.1 9764 3528 ? S 10:12 0:00 nginx: worker process nginx 9149 0.0 0.1 9764 3528 ? S 10:12 0:00 nginx: worker process |
3. 基本的な動作の確認
1. 事前ファイルの取得 (5min)
ラボで必要なファイルをGitHubから取得します
sudo su -
cd ~/
git clone https://github.com/BeF5/f5j-nginx-plus-lab1-conf.git
2. 設定のテスト、設定の反映 (10min)
ディレクトリを移動し、必要なファイルをコピーします
cp ~/f5j-nginx-plus-lab1-conf/lab/incomplete.conf /etc/nginx/conf.d/default.conf
設定ファイルの内容を確認します
cat ~/f5j-nginx-plus-lab1-conf/lab/incomplete.conf
1 2 3 4 5 6 7 8 9 | server { # you need to add ; at end of listen directive. listen 81 server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } } |
基本的なコマンドと、Signalについて以下を確認してください。
-t
と -T
の2つのオプションを実行し、違いを確認します。まず、オプションの内容を確認してください。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # nginx -h nginx version: nginx/1.21.3 (nginx-plus-r25) Usage: nginx [-?hvVtTq] [-s signal] [-p prefix] [-e filename] [-c filename] [-g directives] Options: -?,-h : this help -v : show version and exit -V : show version and configure options then exit -t : test configuration and exit -T : test configuration, dump it and exit -q : suppress non-error messages during configuration testing -s signal : send signal to a master process: stop, quit, reopen, reload -p prefix : set prefix path (default: /etc/nginx/) -e filename : set error log file (default: /var/log/nginx/error.log) -c filename : set configuration file (default: /etc/nginx/nginx.conf) -g directives : set global directives out of configuration file |
テストを実行します(-t
)
nginx -t
1 2 | nginx: [emerg] invalid parameter "server_name" in /etc/nginx/conf.d/default.conf:4 nginx: configuration file /etc/nginx/nginx.conf test failed |
vi /etc/nginx/conf.d/default.conf
1 2 3 4 5 | listen directiveの文末に ; を追加してください。 --- [変更前] listen 81 [変更後] listen 81; --- |
-t
の実行nginx -t
1 2 | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful |
-T
の実行
nginx -T
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful # configuration file /etc/nginx/nginx.conf: user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } ※省略※ # configuration file /etc/nginx/conf.d/default.conf: server { # you need to add ; at end of listen directive. listen 81; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } } |
nginx -s reload
ss -anp | grep nginx | grep LISTEN
1 | tcp LISTEN 0 511 0.0.0.0:81 0.0.0.0:* users:(("nginx",pid=9341,fd=12),("nginx",pid=9340,fd=12),("nginx",pid=9147,fd=12)) |
curlコマンドを実行します
curl -s localhost:81 | grep title
1 | <title>Welcome to nginx!</title> |
3. 設定の継承 (10min)
ラボで使用するファイルをコピーします
cp -r ~/f5j-nginx-plus-lab1-conf/html /etc/nginx/conf.d
cp ~/f5j-nginx-plus-lab1-conf/lab/inheritance.conf /etc/nginx/conf.d/default.conf
listen 80では、indexを個別に記述をしていません。 listen 8080では、 indexとして main.html を指定しています。 また、それぞれ root の記述方法が異なっています。
cat ~/f5j-nginx-plus-lab1-conf/lab/inheritance.conf
1 2 3 4 5 6 7 8 9 10 | index index.html; server { listen 80; root conf.d/html; } server { listen 8080; root /etc/nginx/conf.d/html; index main.html; } |
設定を反映し、これらがどのように動作するのか見てみましょう
nginx -s reload
ss -anp | grep nginx | grep LISTEN
1 2 | tcp LISTEN 0 511 0.0.0.0:8080 0.0.0.0:* users:(("nginx",pid=9392,fd=9),("nginx",pid=9391,fd=9),("nginx",pid=9147,fd=9)) tcp LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=9392,fd=8),("nginx",pid=9391,fd=8),("nginx",pid=9147,fd=8)) |
Port 80 に対し、curlコマンドを実行します
curl -s localhost:80 | grep path
1 | <h2>path: html/index.html</h2> |
Port 8080 に対し、curlコマンドを実行します
curl -s localhost:8080 | grep path
1 | <h2>path: html/main.html</h2> |
4. server directive (10min)
NGINXが通信を待ち受ける動作について以下を確認してください
ラボで使用するファイルをコピーします
cp ~/f5j-nginx-plus-lab1-conf/lab/blank-defaultbehavior.conf /etc/nginx/conf.d/default.conf
設定内容を確認します
cat ~/f5j-nginx-plus-lab1-conf/lab/blank-defaultbehavior.conf
1 2 3 | server { } |
設定を反映します
nginx -s reload
ss -anp | grep nginx | grep LISTEN
1 | tcp LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=9445,fd=8),("nginx",pid=9444,fd=8),("nginx",pid=9147,fd=8)) |
curl localhost:80
1 2 3 4 5 6 | <html> <head><title>404 Not Found</title></head> <body> <center><h1>404 Not Found</h1></center> <hr><center>nginx/1.21.3</center> </body> |
これらの内容より、server directiveに設定を記述しない場合にも、defaultのパラメータで動作していることが確認できます。
それでは対象となるディレクトリにファイルをコピーします
mkdir /etc/nginx/html
cp /etc/nginx/conf.d/html/default-path_index.html /etc/nginx/html/index.html
curl -s localhost:80 | grep default
1 | <h2>This is default html file path</h2> |
今度は正しく結果が表示されました。 このようにdefaultパラメータの動作を確認できました
5. listen directive (10min)
ラボで使用するファイルをコピーします
cp ~/f5j-nginx-plus-lab1-conf/lab/multi-listen.conf /etc/nginx/conf.d/default.conf
設定内容を確認し、反映します
cat ~/f5j-nginx-plus-lab1-conf/lab/multi-listen.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # server { # ## no listen directive # } server { listen 127.0.0.1:8080; } server { listen 127.0.0.2; } server { listen 8081; } server { listen unix:/var/run/nginx.sock; } |
設定を反映します
service nginx restart
ソケットが生成されていることを確認します
ls /var/run/nginx.sock
1 | /var/run/nginx.sock
|
NGINXでListenしている内容を確認します
ss -anp | grep nginx | grep LISTEN
1 2 3 4 | u_str LISTEN 0 511 /var/run/nginx.sock 60394 * 0 users:(("nginx",pid=9947,fd=9),("nginx",pid=9946,fd=9),("nginx",pid=9945,fd=9)) tcp LISTEN 0 511 127.0.0.2:80 0.0.0.0:* users:(("nginx",pid=9947,fd=7),("nginx",pid=9946,fd=7),("nginx",pid=9945,fd=7)) tcp LISTEN 0 511 127.0.0.1:8080 0.0.0.0:* users:(("nginx",pid=9947,fd=6),("nginx",pid=9946,fd=6),("nginx",pid=9945,fd=6)) tcp LISTEN 0 511 0.0.0.0:8081 0.0.0.0:* users:(("nginx",pid=9947,fd=8),("nginx",pid=9946,fd=8),("nginx",pid=9945,fd=8)) |
それぞれ Listen している内容に対して接続できることを確認してください
curl -s 127.0.0.1:8080 | grep default
1 | <h2>This is default html file path</h2> |
curl -s 127.0.0.2:80 | grep default
1 | <h2>This is default html file path</h2> |
curl -s 127.0.0.1:8081 | grep default
1 | <h2>This is default html file path</h2> |
curl -s --unix-socket /var/run/nginx.sock http: | grep default
1 | <h2>This is default html file path</h2> |
socketを削除し、NGINXが起動することを確認します
rm /var/run/nginx.sock
rm /etc/nginx/conf.d/default.conf
service nginx restart
6. server_name directive (10min)
server_name directiveを利用することにより、待ち受けるFQDNを指定することが可能です。
ラボで使用するファイルをコピーします
cp ~/f5j-nginx-plus-lab1-conf/lab/multi-server_name.conf /etc/nginx/conf.d/default.conf
設定内容を確認し、反映します
cat ~/f5j-nginx-plus-lab1-conf/lab/multi-server_name.conf
実行結果を確認します
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | server { server_name example.com; return 200 "example.com\n"; } server { server_name host1.example.com; return 200 "host1.example.com\n"; } server { server_name www.example.*; return 200 "www.example.*\n"; } server{ server_name *.org; return 200 "*.org\n"; } server { server_name *.example.org; return 200 "*.example.org\n"; } server { listen 80; server_name ~^(www2|host2).*\.example\.com$; return 200 "~^(www2|host2).*\.example\.com\n"; } server { listen 80; server_name ~^.*\.example\..*$; return 200 "~^.*\.example\..*\n"; } server { listen 80; server_name ~^(host2|host3).*\.example\.com$; return 200 "~^(host2|host3).*\.example\.com\n"; } |
設定を反映します
nginx -s reload
server_nameの処理順序は以下です
以下のコマンドを実行し結果を確認します。 どのような処理が行われているか確認してください
完全一致する結果を確認します
curl localhost -H 'Host:host1.example.com'
1 | host1.example.com
|
Wild Cardの前方一致する結果を確認します
curl localhost -H 'Host:www.example.co.jp'
1 | www.example.*
|
正規表現のはじめに一致する結果を確認します
curl localhost -H 'Host:host2.example.co.jp'
1 | ~^.*\.example\..* |
curl localhost -H 'Host:host2.example.com'
1 | ~^(www2|host2).*\.example\.com |
7. location directive (10min)
ラボで使用するファイルをコピーします
cp ~/f5j-nginx-plus-lab1-conf/lab/multi-location.conf /etc/nginx/conf.d/default.conf
設定内容を確認し、反映します
cat ~/f5j-nginx-plus-lab1-conf/lab/multi-location.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | server { listen 80; location / { return 200 "LOCATION: / , URI: $request_uri, PORT: $server_port\n"; } location ~* \.(php|html)$ { return 200 "LOCATION: ~* \.(php|html), URI: $request_uri, PORT: $server_port\n"; } location ^~ /app1 { return 200 "LOCATION: ^~ /app1, URI: $request_uri, PORT: $server_port\n"; } location ~* /app1/.*\.(php|html)$ { return 200 "LOCATION: ~* /app1/.*\.(php|html), URI: $request_uri, PORT: $server_port\n"; } location = /app1/index.php { return 200 "LOCATION: = /app1/index.php, URI: $request_uri, PORT: $server_port\n"; } location /app2 { return 200 "LOCATION: /app2, URI: $request_uri, PORT: $server_port\n"; } location ~* /app2/.*\.(php|html)$ { return 200 "LOCATION: ~* /app2/.*\.(php|html), URI: $request_uri, PORT: $server_port\n"; } } |
設定を反映します。
nginx -s reload
locationの処理順序は以下となります。
期待した結果となることを確認してください
前方一致する結果を確認
curl http://localhost/app1/index.html
1 | LOCATION: ^~ /app1, URI: /app1/index.html, PORT: 80 |
正規表現で一致する結果を確認
curl http://localhost/app2/index.html
1 | LOCATION: ~* \.(php|html), URI: /app2/index.html, PORT: 80 |
8. Proxy (5min)
ラボで使用するファイルをコピーします
cp ~/f5j-nginx-plus-lab1-conf/lab/proxy.conf /etc/nginx/conf.d/default.conf
設定内容を確認し、反映します
cat ~/f5j-nginx-plus-lab1-conf/lab/proxy.conf
1 2 3 4 5 6 7 8 9 10 | server { listen 80; location /app1 { proxy_pass http://backend1:81/otherapp; } location /app2 { proxy_pass http://backend1:81; } } |
設定を反映します
nginx -s reload
以下のコマンドを実行し結果を確認します。 どのような処理が行われているか確認してください。
curl -s localhost/app1/usr1/index.php | jq .
1 2 3 4 5 | { "request_uri": "/otherapp/usr1/index.php", "server_addr": "10.1.1.8", "server_port": "81" } |
curl -s localhost/app2/usr1/index.php | jq .
1 2 3 4 5 | { "request_uri": "/app2/usr1/index.php", "server_addr": "10.1.1.8", "server_port": "81" } |
9. Load Balancing (5min)
ラボで使用するファイルをコピーします
cp ~/f5j-nginx-plus-lab1-conf/lab/lb-weight.conf /etc/nginx/conf.d/default.conf
cp ~/f5j-nginx-plus-lab1-conf/lab/lb-weight_plus_api.conf /etc/nginx/conf.d/plus_api.conf
設定内容を確認し、反映します
cat ~/f5j-nginx-plus-lab1-conf/lab/lb-weight.conf
1 2 3 4 5 6 7 8 9 10 11 | upstream server_group { zone backend 64k; server backend1:81 weight=1; server backend2:82 weight=2; } server { listen 80; location / { proxy_pass http://server_group; } } |
Note
API、APIを活用したDashboardの機能は NGINX Plus
の機能となります。 NGINX OSS
では利用できません。
cat ~/f5j-nginx-plus-lab1-conf/lab/lb-weight_plus_api.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | server { listen 8888; access_log /var/log/nginx/mng_access.log; location /api { api write=on; # directives limiting access to the API } location = /dashboard.html { root /usr/share/nginx/html; } } |
設定を反映します
nginx -s reload
作業を行うホストからブラウザでNGINX Plus Dashboardを開く場合、 ``ubuntu01``の接続はメニューより ``PLUS DASHBOARD``をクリックしてください。 踏み台ホストから接続する場合、ブラウザで http://10.1.1.7:8888/dashboard.html を開いてください
以下コマンドを実行し、適切に分散されることを確認します。
for i in {1..9}; do echo "==$i==" ; curl -s localhost | jq . ; sleep 1 ; done
1 2 3 4 5 6 7 8 9 10 11 12 13 | ==1== { "request_uri": "/", "server_addr": "10.1.1.8", "server_port": "82" } ※省略※ ==9== { "request_uri": "/", "server_addr": "10.1.1.8", "server_port": "82" } |
Dashboardの結果が適切なweightで分散されていることを確認してください。
10. トラフィックの暗号化 (5min)
ラボで使用するファイルをコピーします
cp -r ~/f5j-nginx-plus-lab1-conf/ssl /etc/nginx/conf.d
cp ~/f5j-nginx-plus-lab1-conf/lab/ssl.conf /etc/nginx/conf.d/default.conf
設定内容を確認し、反映します
cat ~/f5j-nginx-plus-lab1-conf/lab/ssl.conf
1 2 3 4 5 6 7 8 9 | server { listen 80; listen 443 ssl; ssl_certificate_key conf.d/ssl/nginx-ecc-p256.key; ssl_certificate conf.d/ssl/nginx-ecc-p256.pem; location / { proxy_pass http://backend1:81; } } |
設定を反映します
nginx -s reload
以下のコマンドを実行し結果を確認します。
HTTPでのアクセスを確認
curl -v http://localhost
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | * Trying 127.0.0.1:80... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 80 (#0) > GET / HTTP/1.1 > Host: localhost > User-Agent: curl/7.68.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < Server: nginx/1.21.3 < Date: Mon, 22 Nov 2021 15:05:35 GMT < Content-Type: application/octet-stream < Content-Length: 65 < Connection: keep-alive < * Connection #0 to host localhost left intact { "request_uri": "/","server_addr":"10.1.1.8","server_port":"81"} |
HTTPSでのアクセスを確認
curl -kv https://localhost
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | * Trying 127.0.0.1:443... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Server key exchange (12): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / ECDHE-ECDSA-AES256-GCM-SHA384 * ALPN, server accepted to use http/1.1 * Server certificate: * subject: CN=localhost * start date: Mar 24 01:04:24 2021 GMT * expire date: Apr 23 01:04:24 2021 GMT * issuer: CN=localhost * SSL certificate verify result: self signed certificate (18), continuing anyway. > GET / HTTP/1.1 > Host: localhost > User-Agent: curl/7.68.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 200 OK < Server: nginx/1.21.3 < Date: Mon, 22 Nov 2021 15:05:49 GMT < Content-Type: application/octet-stream < Content-Length: 65 < Connection: keep-alive < * Connection #0 to host localhost left intact { "request_uri": "/","server_addr":"10.1.1.8","server_port":"81"} |