acme.sh能申请免费的ssl证书,并可以定期 新证书,非常省 。
1. 安装 acme.sh
安装很简单, 一个命令:
curl https://get.acme.sh | sh
普通用户和 root 用户都可以安装使用.建议root下执行 安装过程进行了以下几步:
- 把 acme.sh安装到你的 home目录下:
~/.acme.sh/
并创建 一个 bash 的 alias, 方便你的使用: acme.sh=~/.acme.sh/acme.sh
以下是在nginx上的使 步骤──
如果系统的80和443已经被其他虚拟主机运营占 ,则先做 个最普通的80端 的nginx 件
server {
listen 80;
server_name example.com;
location / {
root html;
index index.html index.htm;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
检查配置 件语法错误
nginx -t
重启nginx让虚拟主机 效
systemctl restart nginx
动申请证书,acme.sh会检查nginx对此域名的http header是不是200,通过后把证书复制到 临时 录。
acme.sh --issue --nginx -d example.com --debug
将证书从临时 录部署到nginx/ssl下,但不会修改现有的conf 件
acme.sh --install-cert -d example.com \
--key-file /etc/nginx/ssl/example.com/key.pem \
--fullchain-file /etc/nginx/ssl/example.com/cert.pem \
--reloadcmd "service nginx force-reload"
复制 个现成的带ssl配置的conf替换掉80端 的配置 件
server {
listen 80;
server_name www.ssstk.tk ssstk.tk;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443 ssl http2;
server_name www.ssstk.tk ssstk.tk;
ssl on;
ssl_certificate /etc/nginx/ssl/ssstk.tk/cert.pem;
ssl_certificate_key /etc/nginx/ssl/ssstk.tk/key.pem;
charset utf-8;
access_log /opt/logs/nginx/ssstk.access.log;
error_log /opt/logs/nginx/ssstk.error.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://127.0.0.1:8000;
}
}
分享下使用acme.sh搭建的站点
ssstk过云梯享受科学上网
自己使用GCP搭建的过云梯
注册领取免费时长
速度很快的哦