简体   繁体   English

让我们加密 SSL 抛出 404

[英]Let's Encrypt SSL throwing 404

I just installed nginx on my VPS and created 2 websites on there.我刚刚在我的 VPS 上安装了 nginx 并在那里创建了 2 个网站。

api.school-alert.cz api.school-alert.cz

server {
    server_name  api.school-alert.cz;
    index index.html index.htm;
    access_log /var/log/nginx/bmiapp.log;
    error_log  /var/log/nginx/bmiapp-error.log error;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:8080;
        proxy_redirect off;
    }
}

and school-alert.cz和 school-alert.cz

server {
    server_name  school-alert.cz;
    index index.html index.htm;
    access_log /var/log/nginx/bmiapp.log;
    error_log  /var/log/nginx/bmiapp-error.log error;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        proxy_pass http://127.0.0.1:3000;
        proxy_redirect off;
    }
}

I have already created a certificate for api.school-alert.cz but for some reason, when I try to create certificate for the other domain name I get an error.我已经为 api.school-alert.cz 创建了证书,但由于某种原因,当我尝试为其他域名创建证书时出现错误。 Specificaly when running "certbot --nginx" or "certbot -d school-alert.cz".特别是在运行“certbot --nginx”或“certbot -d school-alert.cz”时。 This is the error I get:这是我得到的错误:

Certbot failed to authenticate some domains (authenticator: nginx). The Certificate Authority reported these problems:
  Domain: school-alert.cz
  Type:   unauthorized
  Detail: 2a02:2b88:1:4::16: Invalid response from http://school-alert.cz/.well-known/acme-challenge/Qo8DXVvUsxXzGda633bnyrcMN6_pnyzP09gce11lNBQ: 404

Hint: The Certificate Authority failed to verify the temporary nginx configuration changes made by Certbot. Ensure the listed domains point to this nginx server and that it is accessible from the internet.

Some challenges have failed.

I have been trying to fix this for days, but didn't find a solution yet, I would greatly appreciate your help.这几天我一直在尝试解决这个问题,但还没有找到解决方案,非常感谢您的帮助。

Both websites are easily accessible on the internet http://api.school-alert.cz:8080/ http://school-alert.cz/这两个网站都可以在互联网上轻松访问http://api.school-alert.cz:8080/ http://school-alert.cz/

api.school-alert.cz is a subdomain of school-alert.cz . api.school-alert.czschool-alert.cz的子域。 From your description, you have created a certificate for the subdomain, but didn't add the domain to the certificate.根据您的描述,您已经为子域创建了证书,但没有将域添加到证书中。

To fix the existing certificate so it works with the domain and subdomain, run:要修复现有证书以使其适用于域和子域,请运行:

sudo certbot nameofcertificate -d school-alert.cz -d api.school-alert.cz -d www.school-alert.cz (sudo may not be necessary if you're using the server plugin for Apache or Nginx.) Add your certificate name where it says "name of certificate." sudo certbot nameofcertificate -d school-alert.cz -d api.school-alert.cz -d www.school-alert.cz (sudo may not be necessary if you're using the server plugin for Apache or Nginx.) Add your证书名称,其中显示“证书名称”。 This is usually your domain's name also.这通常也是您的域名。 You can find the certificate name by running the command sudo certbot certificates .您可以通过运行命令sudo certbot certificates找到证书名称。

Now the domain, subdomain, and www prefixed URL are covered under your current certificate.现在,域、子域和www前缀 URL 已包含在您当前的证书下。

After many days of battling with this problem I found out the real reason for why it was working for my subdomain and not for my domain was that my domain provider has set up default dns records for that domain.在与这个问题斗争了很多天之后,我发现它为什么适用于我的子域而不是我的域的真正原因是我的域提供商已经为该域设置了默认的 dns 记录。 These dns records pointed to a server I do not own, so I couldn't authorize for the ssl certificate.这些 dns 记录指向我不拥有的服务器,因此我无法授权 ssl 证书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM