HTTPS证书生成与Nginx配置
https证书生成
1 https 生成
2 Nginx配置
此处配置仅用于https转发至http端口
server {
listen 5344 ssl;
server_name _;
ssl_certificate /home/config/cert/cert.pem;
ssl_certificate_key /home/config/cert/private.key;
location / {
proxy_pass http://127.0.0.1:5244;
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;
}
}
配置中配置生成的证书文件路径,
- ssl_certificate /home/config/cert/cert.pem;
- ssl_certificate_key /home/config/cert/private.key;
或 - ssl_certificate /usr/local/nginx/cert/ssl.crt;
- ssl_certificate_key /usr/local/nginx/cert/ssl.key;
crt 和 pem 效果一致
配置完毕后,访问https://127.0.0.1:5344 请求会转发至http://127.0.0.1:2544
区别:
PEM是基于Base64编码的证书格式,扩展名包括PEM、CRT和CER。Linux系统使用CRT,Windows系统使用CER。PEM证书通常将根证书、中间证书和用户证书分开存放,主要用于Apache和Nginx。CRT应该是certificate的三个字母,其实还是证书的意思。常见于UNIX系统,有可能是 PEM 编码,也有可能是DER编码,大多数应该是PEM编码。
简单来说,PEM和DER是不同的编码方式,PEM在 linux上常用,DER在 window 上常用,可以相互转换。而CRT是符合ITU-T X509国际标准的DER编码(ASCII)的证书文件格式,目前不作为IIS的主流安装证书文件。

浙公网安备 33010602011771号