Let’s Encrypt申请免费IP证书

2025年12月19日开始正式提供 IP 地址证书的签发,依旧免费。

模式一:无Web (如:Nginx ,Apache)

dnf install -y socat

安装 / 升级 acme.sh (注:my@example.com 不能照抄,随便输入一个邮箱也行)

curl https://get.acme.sh | sh -s
./acme.sh upgrade  #升级

签发证书 1.2.3.4 为你机器IP

./.acme.sh/acme.sh --issue --server letsencrypt --accountemail admin@erw.cn -d 1.2.3.4 --certificate-profile shortlived --days 7 --standalone

命令解释如下:
./acme.sh:执行 acme.sh 脚本
–issue:申请一个新证书
–server letsencrypt:使用 Let’s Encrypt 服务器
-d 1.2.3.4:证书申请的目标是 IP 地址 1.2.3.4
–certificate-profile shortlived:申请一个短期证书(实测最大7天)
–days 3:证书有效期是 3 天
–standalone:使用 standalone 模式验证,不依赖现有的 Web 服务器。

模式二:已有Web 以Nginx举例

Lnmp环境 文件位置

/usr/local/nginx/conf/nginx.conf

宝塔面板 文件位置

/www/server/panel/vhost/nginx/0.default.conf

增加location块内容 以你的为准

server {
    listen 80 default_server;
    server_name _;
    location ~ ^/.well-known/(acme-challenge|pki-validation)/ {
        add_header Content-Type text/plain;
        root /wwwroot/letsencrypt;
    }
}

记得重启或重载Nginx 之后执行如下

./acme.sh --issue --server letsencrypt -d 1.2.3.4 -w /wwwroot/letsencrypt --certificate-profile shortlived --days 8

生成证书存储在

/root/.acme.sh/1.2.3.4_ecc/1.2.3.4.key (私钥)
/root/.acme.sh/1.2.3.4_ecc/fullchain.cer (完整证书链)

Nginx配置SSL证书就没必要说了

自动续签 crontab -e 命令 每周星期五凌晨4点整执行一次

Docker

0 4 * * 5 "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" --reloadcmd "docker exec appinn-nginx-1 nginx -s reload"

机器

0 4 * * 5 "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" --reloadcmd "nginx -s reload"

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注