比如我要把
用F12的network可以看到状态码301,一定不能是302
需要注意的是,只需要nginx开启ssl就行了,tomcat和nginx还是走http就行
所以证书配置,只需要在nginx上配置
配置http不带www的跳转到https带www的
server {
listen ;
server_name gucanhui.com;
return https://www.gucanhui.com$request_uri;
}
然后http带www的跳转到https带www的
server {
listen ;
server_name www.gucanhui.com; #charset koi8-r; #access_log logs/host.access.log main; location / { return https://www.gucanhui.com$request_uri;
}
然后再443端口配置证书和跳转就行了
# HTTPS server
#
server {
listen ssl;
server_name www.gucanhui.com; ssl_certificate gucanhui.com.crt;
ssl_certificate_key gucanhui.com.key; ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on; location / {
proxy_pass http://127.0.0.1:8080;
}
}