====== NginxによるWebサーバー構築 ====== [[:linux|Linux]] ===== インストール ===== まずはdnfモジュールを検索する。 dnf module list nginx dnfモジュールをインストールする。 dnf module install nginx:1.20 ===== リバースプロキシ設定 ===== リバースプロキシを設定するには、 /etc/nginx/conf.d/springboot.conf を編集する。 server { listen 443 ssl; server_name host.example.com; #ホスト名を指定 ssl_certificate /etc/pki/nginx/server.crt; # 証明書のパスを指定 ssl_certificate_key /etc/pki/nginx/private/server.key; # 証明書の秘密鍵のパスを指定 ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { #proxy_set_header X-Forwarded-Proto $scheme; #proxy_set_header Host $http_host; #proxy_set_header Host $host; #proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://localhost:8080/; } } ===== SSL化設定 ====== ''/etc/pki/nginx''ディレクトリ内に証明書、''/etc/pki/nginx/private''ディレクトリ内に秘密鍵を入れる。 ''/etc/nginx/nginx.conf''あるいは''conf.d''以下に設定を置き、 server { listen 443 ssl; server_name localhost; ssl_certificate /etc/pki/nginx/; ssl_certificate_key /etc/pki/nginx/private/; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { proxy_pass http://localhost:8080/; } }