网站颁发免费ssl证书,https

https://github.com/acmesh-official/acme.sh
我使用的是nginx, 主要使用的命令:

curl https://get.acme.sh | sh -s email=my@example.com
source ~/.barshrc
# 使用该命令需要先配置带有域名的nginx 配置文件
acme.sh --issue -d mydomain.com --nginx

nginx 配置文件:

server {
listen 80 ;
listen [::]:80 ;
server_name mydomain.com;
proxy_set_header X-Forwarded-Host $http_host;
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;
location / {
proxy_pass http://localhost:8018;
}
}

执行命令acme.sh --issue -d mydomain.com --nginx 后手动添加ssl 相关配置

server {
listen 80 ;
listen [::]:80 ;
server_name mydomain.com;
proxy_set_header X-Forwarded-Host $http_host;
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;
location / {
proxy_pass http://localhost:8018;
}
}
server {
#监听443端口
listen 443 ;
#你的域名
server_name mydomain.com;
ssl on;
#ssl证书的pem文件路径
ssl_certificate /root/.acme.sh/mydomaincom_ecc/mydomain.com.cer;
#ssl证书的key文件路径
ssl_certificate_key /root/.acme.sh/mydomain.com/mydomain.com.key;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
client_max_body_size 100m;
location / {
proxy_pass http://localhost:8018;
}
}

过程中遇到一个报错

看日志是服务器返回的结果是invalid
执行命令中加个--server letsencrypt, 搞定

自动更新证书==永久免费

posted @   那时一个人  阅读(22)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
历史上的今天:
2023-02-27 odoo queue job 配置文件设置
2020-02-27 编码对象或者字串中包含Unicode字符怎样转换为中文
点击右上角即可分享
微信分享提示