「nginx入門」httpsを設定する方法メモ
1.nginxのSSLモジュールをインストール
#./configure –prefix=/usr/local/nginx –with-http_stub_status_module –with-http_ssl_module –with-http_realip_module
#make
#make install
2.SSLの設定
upstream tomcats {
server 127.0.0.1:8080 weight=10;
}
server {
listen 443;
server_name www.xxx.com;
ssl on;
ssl_certificate /usr/local/cert/xxx.pem;
ssl_certificate_key /usr/local/cert/xxx.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root html;
proxy_pass http://tomcats;
index index.html index.htm;
}
}
3.httpsリダイレクト
rewrite ^(.*)$ https://$host$1 permanent;
location / {
root html;
proxy_pass http://tomcats;
index index.html index.htm;
}
4.nginx再起動
/usr/local/nginx/sbin/nginx -s reload