Skip to content

Nginx (Mandatory Requirements)

概要

Nginx は、本プロジェクトにおける唯一のエントリーポイントとして機能する Web サーバーです。 Docker Infrastructure の課題要件に基づき、TLS v1.2 / v1.3 のみをサポートする HTTPS 設定を行っています。

構成

Dockerfile 解析

(srcs/requirements/nginx/Dockerfile)

  • Base Image: debian:bullseye
  • Install: apt-get install nginx openssl ...
    • (※詳細なコンパイル手順については WAF/ModSecurity を参照)

設定詳細 (nginx.conf)

1. TLS 通信の強制

ポート 443 を開放し、SSL/TLS プロトコルバージョンを厳密に指定しています。

nginx
server {
    listen 443 ssl;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_certificate /etc/nginx/ssl/inception.crt;
    ssl_certificate_key /etc/nginx/ssl/inception.key;
    ...
}
  • これにより、暗号化されていない HTTP 通信や、脆弱性のある古いプロトコル (SSLv3, TLSv1.0, TLSv1.1) は拒否されます。

2. WordPress へのルーティング

ルートパス / へのリクエストは、WordPress コンテナの PHP-FPM (ポート 9000) へ転送されます。

nginx
location / {
    try_files $uri $uri/ =404;
}

location ~ \.php$ {
    fastcgi_pass wordpress:9000;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

証明書の生成

自己署名証明書は、コンテナ起動時(または Makefile 内)で OpenSSL コマンドを使用して生成されます。

bash
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
    -keyout /etc/nginx/ssl/inception.key \
    -out /etc/nginx/ssl/inception.crt \
    -subj "/C=JP/ST=Tokyo/L=Minato/O=MyOrganization/OU=Student/CN=${DOMAIN_NAME}"

参考資料

Released under the MIT License.