内容简介:之前写过一篇 ghost@0.7 上 SSL的文章传送门:这次给 @2.x 上SSL 方式其实90% 是一样的。。。。
之前写过一篇 ghost@0.7 上 SSL的文章
传送门: https://lunashu.org/0yuan-rang-ni-de-wang-zhan-zhi-chi-https/
这次给 @2.x 上SSL 方式其实90% 是一样的。。。。
但是呢。。。唯独有点区别的地方在于 ghost install
或者 ghost setup
的时候提示的 SSL配置一定要选择 no
在 install
或者 setup
的时候的 SSL 配置 是自动关联到 Let's Encrypt
的。。。虽然这是个免费的SSL颁发,但是他每次颁发的SSL证书只有3个月有效期,到期 要手动续签,很麻烦!而且申请也是很麻烦!!!
所以我们还是沿用上一篇文章中的办法,通过 阿里云 或者 腾讯云 去申请一年免费的ssl证书。
之后再按照 上一篇文章中的内容去配置就行啦~ 配置其实还是很简单的。。。
不过有一点注意的是 如果 是通过 ghost install
或 ghost setup
命令创建的 Nginx 配置文件的话,这个 Nginx 配置文件并不在你的 ngix 的 site-enalbed 目录下,而是在你的 Ghost博客目录下的 system -> files
里面
但是 配置完成之后 要重新改动一下 在Ghost博客根目录下的 config.production.json
文件
先 ghost stop <Name>
关闭你的 Ghost博客
然后修改 config.production.json
文件中的 url
的值,把 http
改成 https
修改完之后,在Ghost博客所在的根目录下 通过 ghost start
命令 重新启动 ghost博客
完美!
好了 现在我们的 SSL 配置成功了,接下来,我们做一步额外的工作,把 原来的 http
重定向到 现在的 https
现在我们修改下 Nginx 的 配置文件
server {
listen 443;
listen [::]:443;
ssl on;
ssl_certificate [pem 文件路径];
ssl_certificate_key [key 文件路径];
server_name [你的域名];
root /var/www/<博客目录>/system/nginx-root;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:[port];
}
location ~ /.well-know {
allow all;
}
client_max_body_size 50m;
}
server {
listen 80;
listen [::]:80;
server_name [你的域名];
return 301 https://$server_name$request_uri;
}
好了,我们 重启下Nginx 看下效果吧!
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Haskell School of Music
Paul Hudak、Donya Quick / Cambridge University Press / 2018-10-4 / GBP 42.99
This book teaches functional programming through creative applications in music and sound synthesis. Readers will learn the Haskell programming language and explore numerous ways to create music and d......一起来看看 《The Haskell School of Music》 这本书的介绍吧!