Nginx詳解(三) 使用openssl為nginx生成自簽名證書


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

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 -signkeys 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:瀏覽器訪問測試

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM