打开nginx配置文件,添加配置段:
# HTTPS
server {
listen 443;
server_name www.xxx.com; # 项目域名
ssl on;
ssl_certificate server.crt; #(证书公钥)
ssl_certificate_key server.key; #(证书私钥)
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://192.168.1.11:8086; # tomcat服务器地址
}
}
然后访问https://www.xxx.com 就可以了
如果要实现http强制跳转到https,可以添加下面配置段:
server {
listen 80;
server_name www.xxx.com;
# 跳转到HTTPS
return 301 https://$server_name$request_uri;
}
这里要注意的是
$server_name 就是你的 www.xxx.com
$request_uri 就是请求的资源地址。