You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

官方Certbot Docker镜像默认无NGINX插件,求添加方法及解决方案

解决方案

1. 为官方Certbot镜像添加NGINX插件

官方Alpine版Certbot镜像默认未包含nginx插件,但可以通过PyPI包管理器安装。创建如下自定义Dockerfile:

FROM certbot/certbot:latest
RUN pip install certbot-nginx

执行构建命令生成自定义镜像:

docker build -t my-certbot-with-nginx .

使用该镜像执行证书申请命令即可:

docker run --rm my-certbot-with-nginx certbot --nginx -d example.com

2. 替代方案

  • 直接使用官方组合镜像:官方提供了certbot/nginx镜像,已预装Certbot及nginx插件,无需额外配置,直接运行:
    docker run --rm certbot/nginx certbot --nginx -d example.com
    
  • Webroot模式绕开插件依赖:若不想安装插件,可采用webroot模式获取证书。需先确保你的Nginx已配置对应域名的webroot路径,然后执行:
    docker run --rm -v /your/local/webroot:/var/www/html certbot/certbot certbot certonly --webroot -w /var/www/html -d example.com
    
    获取证书后,手动将证书路径配置到Nginx的SSL配置中即可。

3. Alpine环境安装Certbot NGINX插件的方法

Alpine官方软件源中确实没有python3-certbot-nginx包,唯一可行的方式是通过pip安装:

pip install certbot-nginx

官方Certbot镜像已自带pip工具,直接在容器内执行上述命令即可完成插件安装。

内容的提问来源于stack exchange,提问作者DrusePstrago

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 15:48:13