【问题标题】:Issue using certbot with nginx将 certbot 与 nginx 一起使用的问题
【发布时间】:2019-04-12 21:59:29
【问题描述】:

我实际上正在开发一个 web 应用程序,我使用 Reactjs 作为前端,Golang 作为后端。这 2 个程序分别托管在 Google-Compute-Engine 的 2 个 VM 上。我想通过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 上通过this tutorial 提供我的应用程序。我安装了 software-properties-common,python-certbot-apache certbot 包,但是当我尝试时

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

我在 Google 和此处进行了一些搜索,但仍然无法确定缺少哪个插件或其他解决此问题的方法。

有人有什么想法可以帮助我吗?

非常感谢:)

【问题讨论】:

    标签: reactjs nginx https lets-encrypt certbot


    【解决方案1】:

    我尝试使用 certbot 为我的子域创建 let'sencrypt 证书并遇到以下问题。 命令:

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

    问题:

    请求的 nginx 插件似乎没有安装

    解决方案:

    Ubuntu 20+

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

    早期版本

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

    【讨论】:

    • 在 Ubuntu 20.04 中,包名是 python3-certbot-nginx
    • 你是通过pip安装的,也可以pip install certbot-nginx
    • 适用于 Ubuntu 20+ 的解决方案也适用于 Ubuntu 18。
    • 你是救生员!
    【解决方案2】:

    你需要更换

    apt install python-certbot-nginx
    

    通过

    apt install python3-certbot-nginx
    

    【讨论】:

      【解决方案3】:

      您可以使用以下命令安装 Certbot nginx 插件:

      add-apt-repository ppa:certbot/certbot
      apt update
      apt install python-certbot-nginx
      

      【讨论】:

      • 谢谢,它正在工作,但是当我这样做时安装总是失败sudo certbot --nginx certonly 我认为这是因为我的应用程序没有任何 DNS
      • 是的,域名需要解析到运行 certbot 的服务器,以验证您拥有该域。
      【解决方案4】:

      在 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 wiki page for letsencrypt 中所述。

      【讨论】:

        猜你喜欢
        • 2015-12-06
        • 2023-03-04
        • 1970-01-01
        • 2018-10-05
        • 1970-01-01
        • 2017-03-02
        • 2013-05-12
        • 2015-05-29
        • 2015-01-28
        相关资源
        最近更新 更多