使用nginx的301永久性重定向, 简洁明了。新建一个server来完成这个动作
配置
# 301重定向, 访问http跳转到https
server {
listen 80; #80固定
server_name 域名;
return 301 https://域名$request_uri;
}
我的nginx上的zc_travel.conf
# 301重定向, 访问http跳转到https
server {
listen 80;
server_name 域名;
return 301 https://域名$request_uri;
}
# ssl配置
server {
listen 443 ssl;
server_name 域名;
root html;
index index.html index.htm;
ssl_certificate ../cert/7711987_zc.chenxin6.com.pem;
ssl_certificate_key ../cert/7711987_zc.chenxin6.com.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://localhost:8009;
}
}



