linux:nginx
NginxによるWebサーバー構築
インストール
まずは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/<crt_file>; ssl_certificate_key /etc/pki/nginx/private/<key_file>; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { proxy_pass http://localhost:8080/; } }
linux/nginx.txt · 最終更新: 2025/02/20 15:37 by mikoto