實現效果:http://www.xxx.com 轉至 https://www.xxx.com
在 /etc/nginx/conf.d 裡新增一個文件,名稱為 DomainName.conf
DomainName.conf內容如下
server {
listen 80;
server_name DomainName;
return 301 https://DomainName;
#轉至https
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name DomainName;
ssl on;
ssl_certificate /home/cointech/cointech.crt;
#憑證crt
ssl_certificate_key /home/cointech/cointech.com.tw.key;
#憑證key
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 5m;
ssl_session_cache shared:SSL:5m;
location / {
proxy_pass https://Docker_container_ip/;
#proxy_pass http://Docker_container_ip/;
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_cookie_path / "/; secure";
}
}