【问题标题】:Django & Certbot - unauthorized, Invalid response (HTTPS)Django 和 Certbot - 未经授权的无效响应 (HTTPS)
【发布时间】:2020-08-03 01:34:36
【问题描述】:

我正在尝试使用 Nginx 配置 Certbot (Letsencrypt)。

我得到这个错误:

 - The following errors were reported by the server:

   Domain: koomancomputing.com
   Type:   unauthorized
   Detail: Invalid response from
   http://koomancomputing.com/.well-known/acme-challenge/xvDuo8MqaKvUhdDMjE3FFbnP1fqbp9R66ah5_uLdaZk
   [2600:3c03::f03c:92ff:fefb:794b]: "<html>\r\n<head><title>404 Not
   Found</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>404
   Not Found</h1></center>\r\n<hr><center>"

   Domain: www.koomancomputing.com
   Type:   unauthorized
   Detail: Invalid response from
   http://www.koomancomputing.com/.well-known/acme-challenge/T8GQaufb9qhKIRAva-_3IPfdu6qsDeN5wQPafS0mKNA
   [2600:3c03::f03c:92ff:fefb:794b]: "<html>\r\n<head><title>404 Not
   Found</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>404
   Not Found</h1></center>\r\n<hr><center>"

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address.
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.

在 /etc/nginx/sites-available/koomancomputing :

server {
listen 80;
server_name koomancomputing.com www.koomancomputing.com;

location = /favicon.ico { access_log off; log_not_found off; }
location /staticfiles/ {
    root /home/kwaku/koomancomputing;
}

location /media/ {
    root /home/kwaku/koomancomputing;
}

location / {
    include proxy_params;
    proxy_pass http://unix:/run/gunicorn.sock;
}
}

我的 DNS A/AAAA 记录:

我不知道该怎么做,所以我搜索并找到了 django-letsencrypt 应用程序,但我不知道如何使用:

【问题讨论】:

  • 你能解决这个问题吗?

标签: django nginx https certbot


【解决方案1】:
server {
  listen 80;
  listen [::]:80;

  # other configuration
}

添加此重启 nginx 后适用于 IPV4 和 IPV6。

【讨论】:

    【解决方案2】:

    您的域通过 IPv6 为您的服务器配置了正确的 AAAA 记录,而 certbot 选择它来验证您的服务器。

    但是,您在 nginx 下配置的服务器块仅侦听您域的 IPv4 上的端口 80。当 certbot 请求 Let's Encrypt 访问您的质询并颁发证书时,nginx 未配置为正确响应 IPv6 上的质询。在这种情况下,它通常会返回其他内容(例如您的情况下的 404 或默认站点)。

    您可以通过修改前两行来解决此问题,以便同时监听您服务器的所有 IPv6 地址:

    server {
      listen 80;
      listen [::]:80;
    
      # other configuration
    }
    

    编辑完成后,重启nginx,再次运行certbot。

    【讨论】:

      【解决方案3】:

      您的 Nginx 服务器响应 404 错误,因为它没有定义 certbot 验证挑战所需的到 /.well-known 的路由。您需要修改 Nginx 配置文件以告诉它如何响应 certbot 的挑战。

      Certbot 可以为您更新 Nginx 配置文件。

      • 首先,确保您的配置文件已启用。运行sudo service nginx reload 并检查是否存在名为/etc/nginx/sites-enabled/koomancomputing 的文件。

      • 然后,运行certbot --nginx -d koomancomputing.com -d www.koomancomputing.com

      --nginx 标志告诉 certbot 查找具有匹配服务器名称的 Nginx 配置文件,并使用 SSL 信息更新该文件。

      【讨论】:

      • 还是同样的问题
      猜你喜欢
      • 1970-01-01
      • 2015-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-26
      • 1970-01-01
      • 2013-06-07
      相关资源
      最近更新 更多