- edge 改为自定义镜像:官方 nginx + certbot + dns-cloudflare 插件 - pangolin-entrypoint.sh:后台每12h certbot renew,续期后本容器内 nginx -s reload - 不再需要宿主 cron / docker socket / 独立 certbot 服务做日常续期 - /etc/letsencrypt 改 rw 挂载,挂入 cloudflare.ini - compose 去掉 build:(宿主 docker-compose 不支持 compose build),改脚本 docker build - deploy.sh/cutover.sh: docker build -t pangolin-edge:local 后再 up Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
# pangolin-edge:官方 nginx + certbot(DNS-01/Cloudflare),让分发层容器自己续签自己用的证书。
|
||||
FROM nginx:1.27-alpine
|
||||
|
||||
# certbot + Cloudflare DNS 插件(EC2 实测:certbot 3.0.1)
|
||||
RUN apk add --no-cache certbot certbot-dns-cloudflare
|
||||
|
||||
COPY pangolin-entrypoint.sh /usr/local/bin/pangolin-entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/pangolin-entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/pangolin-entrypoint.sh"]
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
# pangolin-edge 入口:前台跑 nginx,后台跑证书续期(续期后在【本容器内】热重载 nginx)。
|
||||
# 续期 = certbot renew(DNS-01/Cloudflare),无需 docker socket / 宿主 cron / 跨容器信号。
|
||||
set -e
|
||||
|
||||
# 后台续期循环:每 12h 检查一次;有证书续期则热重载,无则什么都不做。
|
||||
(
|
||||
# 启动后先等一会,避免与 nginx 启动抢资源
|
||||
sleep 60
|
||||
while true; do
|
||||
if certbot renew --quiet --deploy-hook "nginx -s reload"; then
|
||||
:
|
||||
else
|
||||
echo "[pangolin] certbot renew 失败,下个周期重试" >&2
|
||||
fi
|
||||
sleep 12h
|
||||
done
|
||||
) &
|
||||
|
||||
# 前台:沿用官方入口脚本(会执行 /docker-entrypoint.d/*)再启动 nginx
|
||||
exec /docker-entrypoint.sh nginx -g 'daemon off;'
|
||||
Reference in New Issue
Block a user