阿里云域名配置https(免费版)
登錄阿里云找到自己的域名
開啟SSL證書
選擇購買兩年以跳轉到購買免費版頁面
選擇免費版,立即購買
購買成功,跳轉證書控制臺
申請證書
填寫申請資料
按要求驗證
驗證成功,提交審核
Nginx配置證書并將http請求轉發到https
下載證書并上傳到ngixn服務器
上傳到ngixn服務器(隨便放什么位置,配置ngixn.conf文件時設置相應的值就可以)
找到nginx配置文件并配置一個server
server {
listen 443 ssl;
server_name 要設置的域名;
root html;
index index.html index.htm;
ssl_certificate .pem后綴的證書位置,如:/usr/local/nginx/conf/cert/3478976_abc.baidu.com.pem;
ssl_certificate_key .key后綴的證書位置,如:/usr/local/nginx/conf/cert/3478976_abc.baidu.com.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 ~*^.+$ {
proxy_redirect off;
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_pass 請按自身情況設置;
}
}
#可選配置,配置http重定向到https
server
{
listen 80;
server_name 要設置的域名;
rewrite ^(.*)$ https://$host$1 permanent; #將所有http請求通過rewrite重定向到https。
location ~*^.+$ {
proxy_redirect off;
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_pass 請按自身情況設置;
}
}
重新啟動ngixn,完成!現在訪問http會自動跳轉到https了
問題:the "ssl" parameter requires ngx_http_ssl_module
root@iZj6cd6z27o4s242bij2ylZ:/usr/local/nginx/sbin$ ./nginx -s reload
nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:112
root@iZj6cd6z27o4s242bij2ylZ:/usr/local/nginx/sbin$
參考:https://blog.csdn.net/u011294519/article/details/84933823
https://blog.csdn.net/a873217486/article/details/106097855
https://blog.csdn.net/weixin_38111957/article/details/81283121
總結
以上是生活随笔為你收集整理的阿里云域名配置https(免费版)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 软件构造学习笔记-第四周
- 下一篇: 2000元如何升级家用游戏电脑如何升级游