轉(zhuǎn)載請(qǐng)附原文鏈接:http://blog.fandong.me/2017/03/29/aliyun-https/
阿里云提供了免費(fèi)的SSL證書(見下圖)
然后申請(qǐng)了SSL證書虱饿,配置好 這時(shí)候發(fā)現(xiàn)通過非https地址同樣能訪問成功躲撰,才想起忘記設(shè)置強(qiáng)制跳轉(zhuǎn)砖顷。 方法如下
#第一步:修改nginx安裝目錄下的nginx.conf
server {
listen???????80?default_server;
listen???????[::]:80?default_server;
server_name??_;
rewrite?^(.*)$?https://fandong.studio$1?permanent;
root?????????/usr/share/nginx/html;
#?Load?configuration?files?for?the?default?server?block.
include?/etc/nginx/default.d/*.conf;
location?/?{
}
error_page?404?/404.html;
location?=?/40x.html?{
}
error_page?500?502?503?504?/50x.html;
location?=?/50x.html?{
}
}
我的域名是fandong.studio,所以我設(shè)置了https://fandong.studio
#第二步:重啟Nginx
cd /etc/nginx/
到安裝目錄
ps -ef|grep nginx
看nginx master process
root? ? ? 5086? ? 1? 0 13:44 ?? ? ? ? 00:00:00 nginx: master process nginx
nginx?????5087??5086??0?13:44??????????00:00:00?nginx:?worker?process
root??????7337??7317??0?20:44?pts/0????00:00:00?grep?--color=auto?nginx
master process 5086
kill -QUIT 5086
殺掉進(jìn)程
nginx
啟動(dòng)nginx
#第三步:清除瀏覽器緩存刁卜,重新試試吧