配置pem证书
1、从证书出售商获取证书文件,并复制到nginx的conf目录下
2、打开nginx.conf配置文件,写入以下代码
server {
listen 443 ssl;
server_name 域名;
ssl_certificate pem证书本地地址;
ssl_certificate_key key证书本地地址;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
index index.html index.htm;
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_set_header X-Forwarded-Proto $scheme;
proxy_pass 转发的内网加端口;
}
}
配置crt证书
从 https://manage.sslforfree.com/ 免费ssl证书官网上下下来的证书需要把 ca_bundle.crt 的内容全部复制到追加到 certificate.crt 后面,然后将文件上传。
server {
listen 443 ssl;
server_name 你的域名;
ssl_certificate 证书crt.crt;
ssl_certificate_key 证书key.key;
location / {
index index.php index.html index.htm;
root html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
其他参考:https://blog.csdn.net/m0_49194578/article/details/121566493