6.HTTPS协议配置
source link: http://muyunyun.cn/blog/mx5pvgl1/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Https 协议配置
免费的 Https 证书,最多只有一年的期限,而且每个二级子域名要单独申请,很浪费时间。使用本文提供的方法,可以只配置一次,实现证书永久自动续期。
acme.sh 安装实践
笔者一开始将 acme.sh 安装在树莓派中,绕了弯。应将 acme.sh 安装在云服务器端。
- 步骤一: 安装 acme.sh。
- 步骤二: 获取 https 证书。
说明: 本文以 www.muyunyun.cn 作为案例演示,基于树莓派搭建家庭服务器 中的 frp.muyunyun.cn 如果要配置为 HTTPS,操作同理。
在这一步中 acme.sh 读取了 nginx 配置(路径: /etc/nginx/conf.d/www.muyunyun.cn.conf
),并自动生成了证书。
调试方法: acme.sh --issue -d www.muyunyun.cn --nginx --debug 2
- 步骤三: 将证书拷贝到
/etc/nginx/ssl
文件夹。
创建文件夹
拷贝证书:
请一定使用以上语法 acme.sh --install-cer 进行拷贝,这样证书才能保证在新的位置也能自动更新。
- 步骤四: 将
/etc/nginx/ssl/www.muyunyun.cn/
中的证书手动配置到 nginx, 并重启 nginx 使之生效。
将 /etc/nginx/conf.d/www.muyunyun.cn.conf
中的内容替换为:
重启 nginx:
打开 https://www.muyunyun.cn,证书已生效。
由于我们全程使用 acme.sh 进行安装,acme.sh 会自动为你创建一个定时任务, 每天 0:00 点自动检测所有的证书, 如果快过期了, 需要更新, 则会自动更新证书。
运行 ps aux | grep acme
可以看到 acme 一直在后台运行。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK