nginx ssl配置
Step1:检查openssl安装
[root@LFS ~]# rpm -qa openssl
openssl-1.1.1c-15.el8.x86_64
Step2:创建key
[root@LFS ~]# mkdir /ssl
[root@LFS ~]# cd /ssl/
[root@LFS ssl]# openssl genrsa -out server.key 4096
openssl genrsa 生成 RSA 私有秘钥,不会生成公钥,因为公钥提取自私钥。生成时是可以指定私钥长度和密码保护生成了一个4096字节的文件server.key,生成证书签署请求CSR
Step3:生成csr请求文件
[root@LFS ssl]# openssl req -new -key server.key -out server.csr
Step4:CRT生成
[root@LFS ssl]# openssl x509 -req -days 90 -in server.csr -signkey server.key -out server.crt
Step5:启用nginx.conf文件中ssl部分
[root@LFS ssl]# vim /usr/local/nginx/etc/nginx.conf
server {
listen 443 ssl;
server_name localhost;
ssl_certificate /ssl/server.crt;
ssl_certificate_key /ssl/server.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}
Step6:重启nginx服务
[root@LFS ssl]# service nginx restart
Step7:浏览器访问测试