1.服務器域名解析
2.域名申請免費ssl證書
3.把證書下載到服務器解壓
4.配置nginx的配置文件
server { listen 18080 ssl; server_name www.shoubanchengshi.com; #需要將yourdomain.com替換成證書綁定的域名。 ssl_certificate /www/server/nginx/conf/cert/shoubanchengshi.com_bundle.pem; #pem證書路徑 ssl_certificate_key /www/server/nginx/conf/cert/shoubanchengshi.com.key; #pem證書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; #表示使用的TLS協議的類型 ssl_prefer_server_ciphers on; location / { # 轉發到 http 服務器中 proxy_pass http://localhost:8080; #proxy_redirect http:// https://; #add_header Cache-Control no-store; #proxy_set_header Host $host; #proxy_set_header X-Real-IP $remote_addr; #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
listen 18080 ssl; 這裏也可以寫成 listen 443 ssl;就是默認域名訪問
listen 18080 ssl; 則需要域名加端口號訪問
參考文章:https://blog.csdn.net/a704397849/article/details/118682381