This commit is contained in:
张威33321
2026-09-08 20:36:17 +08:00
parent 58d65188a1
commit fb87be680d
19 changed files with 398 additions and 212 deletions

View File

@@ -1,27 +1,27 @@
# Nginx Docker image
# 包含自定义配置的反向代理
# 使用官方 Nginx 镜像
FROM nginx:09051708
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/nginx:alpine
# 维护者信息
LABEL maintainer="awei"
LABEL description="HTTP server with SSL support"
LABEL maintainer="StoneLan"
LABEL description="Nginx reverse proxy container"
# 复制 nginx 配置
# 复制配置文件
# conf.d 只放不依赖证书的常驻配置80 端口ACME 验证 + HTTPS 跳转)
COPY nginx.conf /etc/nginx/nginx.conf
COPY conf.d /etc/nginx/conf.d
COPY verification.html /usr/share/nginx/html/verification.html
# 复制静态文件
COPY html /usr/share/nginx/html
# 创建日志目录与 HTTPS 配置目录
# ssl.d 必须存在nginx.conf 里的 wildcard include 在目录不存在时会报 emerg
RUN mkdir -p /var/log/nginx /etc/nginx/ssl.d
# 创建必要的目录
RUN mkdir -p /var/log/nginx && \
mkdir -p /etc/nginx/ssl && \
chown -R nginx:nginx /var/log/nginx && \
chown -R nginx:nginx /etc/nginx
# 暴露端口
EXPOSE 80
EXPOSE 8443
EXPOSE 80 443
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost/ || exit 1
# 健康检查:/healthz 固定返回 200不跟随 301冷启动阶段也不会误判
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 -O /dev/null http://127.0.0.1/healthz || exit 1
# 启动 Nginx
CMD ["nginx", "-g", "daemon off;"]