申请证书并且上传
可以在腾讯云中下载免费的ssl证书
然后用scp命令上传到服务器
1 2 3 4 5 6
| scp local_file remote_username@remote_ip:remote_folder
scp /home/space/music/1.mp3 root@www.runoob.com:/home/root/others/music
scp /home/space/music/1.mp3 root@www.runoob.com:/home/root/others/music/001.mp3
|
1 2 3 4 5 6
| /home/ubuntu/certfile/xxxx.crt ...
sudo vim /etc/nginx/sites-available/default
|
开启https
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| server { listen 443; server_name www.fogsail.net; ssl on; root /var/www/hexo; index index.html index.htm; ssl_certificate /home/ubuntu/certfile/1_www.domain.com_bundle.crt; ssl_certificate_key /home/ubuntu/certfile/2_www.domain.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 / { index index.html index.htm; } } server { listen 80; server_name www.fogsail.net; rewrite ^(.*)$ https://$host$1 permanent; }
|
1
| 注意,最后的rewrite强制使用https访问
|