一. 阿里云申请免费https证书
https://common-buy.aliyun.com/?spm=5176.2020520163.cas.1.5fdbb137e758gi&commodityCode=cas#/buy
二. 配置 Nginx 的 HTTPS
1. 创建一个存储证书的目录:
在Nginx主目录下创建cert文件夹,在cert文件夹内创建cjjk文件夹
C:\infinit-server\nginx\cert\cjjk
2. 上传 .key 和 .pem 到cjjk文件夹内
3. 创建Nginx的监听文件,监听443端口
C:\infinit-server\nginx\conf\conf.d\cjjk.conf
server {
listen 443;
server_name cjjk.wxclgl.com;
ssl on;
# root /mnt/www/ninghao.org;
index index.html;
location / {
proxy_pass https://cjjk.wxclgl.com:8443;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
ssl_certificate C:/infinit-server/nginx/cert/cjjk.wxclgl/214483049150406.pem;
ssl_certificate_key C:/infinit-server/nginx/cert/cjjk.wxclgl/214483049150406.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
ssl_prefer_server_ciphers on;
}
4. 重启Nginx
net stop nginx
net start nginx
三. 配置 Tomcat 的 HTTPS (PFX证书)
1. 在Tomcat的安装目录下创建cert目录
C:\infinit-server\tomcat\cert\cjjk
2. 把 .key .pem .pfx .txt拷贝到cert目录
3. 修改server.xml文件,找到 Connection port="8443"标签,取消掉注释,添加如下代码
keystoreFile="cert/214483049150406.pfx"
keystoreType="PKCS12"
#此处的证书密码,请参考附件中的密码文件或在第1步中设置的密码
keystorePass="证书密码"
完整配置如下,其中port属性根据实际情况修改
<Connector port="8443"
protocol="HTTP/1.1"
URIEncoding="UTF-8"
SSLEnabled="true"
scheme="https"
secure="true"
keystoreFile="cert/214483049150406.pfx"
keystoreType="PKCS12"
keystorePass="证书密码"
clientAuth="false"
SSLProtocol="TLSv1+TLSv1.1+TLSv1.2"
ciphers="TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256"/>
四.参考资料
阿里云的ssl证书使用说明
https://yundun.console.aliyun.com/?spm=5176.2020520163.0.0.24b0bbeaj2qg1&p=cas#/cas/download/214483049150406?regionId=
用阿里云的免费 SSL 证书让网站从 HTTP 换成 HTTPS
https://ninghao.net/blog/4449
使用Let's Encrypt的SSL证书配置HTTPS手记
https://mp.weixin.qq.com/s/TErsLFziP9-zWke60rokxg
SSL/TLS安全检测报告
https://myssl.com/