使用 Certbot 和 Nginx 出现问题

56

我正在开发一个 Web 应用程序,前端使用 Reactjs,后端使用 Golang。这两个程序分别托管在 Google-Compute-Engine 上的两个虚拟机上。我想通过 https 来提供我的应用程序,因此我选择在生产环境中使用 Nginx 来提供前端服务。首先,我编写了 Nginx 的配置文件:

#version: nginx/1.14.0 (ubuntu)
server {
     listen 80 default_server;
     listen [::]:80 default_server;

     root /var/www/banshee;
     server_name XX.XXX.XX.XXX; #public IP of my frontend VM

     index index.html;

     location / {
       try_files $uri /index.html =404;
     }
   }

这部分一切正常,但之后我想按照 这个教程 ,通过 https 服务我的应用程序。我安装了软件包 software-properties-commonpython-certbot-apachecertbot,但是当我尝试运行

sudo cerbot --nginx certonly

我收到以下消息:

gdes@frontend:/etc/nginx$ sudo certbot --nginx certonly
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Could not choose appropriate plugin: The requested nginx plugin does not appear to be installed
The requested nginx plugin does not appear to be installed

我在谷歌和这里做了一些搜索,但仍然无法确定缺少哪个插件或其他解决方法。

是否有人能帮助我?

非常感谢 :)


插件在Manjaro下被称为certbot-nginx - undefined
5个回答

182

我正在尝试使用Certbot为我的子域名创建Let's Encrypt证书,并出现了以下问题。

命令:

ubuntu@localhost:~$ certbot --nginx -d my_subdomain.website.com -d my_subdomain2.website.com

问题:

请求的Nginx插件似乎未安装

解决方案:

Ubuntu 20+

ubuntu@localhost:~$ sudo apt-get install python3-certbot-nginx

早期版本

ubuntu@localhost:~$ sudo apt-get install python-certbot-nginx


25
在Ubuntu 20.04中,该软件包的名称为 python3-certbot-nginx - Eduard Luca
1
如果您是通过pip安装的,您也可以使用pip install certbot-nginx - Charles L.
Ubuntu 20+的解决方案同样适用于Ubuntu 18。 - margenn

23
您需要更换。
apt install python-certbot-nginx

通过

apt install python3-certbot-nginx

8
您可以使用以下命令安装Certbot nginx插件:
add-apt-repository ppa:certbot/certbot
apt update
apt install python-certbot-nginx

谢谢,它正在工作,但是当我执行 sudo certbot --nginx certonly 时安装仍然失败。我认为这是因为我的应用程序没有任何 DNS。 - G.D
2
是的,域名需要解析到运行Certbot的服务器上,以便验证您拥有该域名。 - RoseHosting

2
您需要重新安装一个Python3版本的Let's Encrypt的certbot。
运行:
sudo apt-get install python3-certbot-nginx

0
在Debian 10上,certbot会返回一个“找不到可用的nginx二进制文件”的问题,因为PATH中缺少“/usr/sbin”。请将“/usr/sbin”添加到PATH中。
export PATH=/usr/sbin:$PATH

然后certbot可以为nginx创建证书。

certbot --nginx -d <server name> --post-hook "/usr/sbin/service nginx restart"

如在Debian Let's Encrypt Wiki页面中所述。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接