如果你开启了自动获取https证书,那么80端口就一定会被caddy占用,因为这是用来从let's encryt申请证书用的,其实获取完毕后端口就不需要占用了,但是caddy还是会一直占着,解决办法就是手动输入密钥。
手动申请免费证书
进行前请务必保证80端口没有被占用,不然会验证失败。
git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
./letsencrypt-auto certonly --standalone --email [email protected] -d website.com -d www.website.com
这里的[email protected]是你的邮箱,website.com是你域名
完成后,证书文件会生成在/etc/letsencrypt/live/{你的域名}/目录下
这是caddy配置文件,笔者将证书文件放在了root下
www.website.com:443 {
tls /root/encrypt/fullchain.pem /root/encrypt/privkey.pem
timeouts none
}
最后重启caddy
sudo systemctl restart caddy.service
letsencrypt续期
./letsencrypt-auto certonly --renew-by-default --email [email protected] -d website.com -d www.website.com
最后一次更新于2019-07-08



caddy版本2.6.2,我设置了非标准HTTPS端口,使用域名访问,自动TLS;但是在看到日志上获取证书完成后,仍然占用80端口,在caddyfile全局选项中添加了auto_https disable_redirects选项禁用HTTPS自动重定向后解决问题。所以好像80端口常驻占用不一定是开启了自动https?
By none at January 8th, 2025 at 04:12 pm.