【发布时间】:2020-01-17 22:46:25
【问题描述】:
这可能是一个简单的错误,但我似乎无法使用certbot 来验证我的域。我正在使用连接到快速应用程序的 nginx。我已经注释掉了默认 nginx 文件中的配置,它只包含来自/etc/nginx/conf.d/mysite.info 的我的站点的配置。在我的配置中,第一个位置条目指向根 /.well-known/acme-challenge 目录。这是我的 nginx conf 文件中的设置:
server {
listen 80;
server_name <MYDOMAIN>.info www.<MYDOMAIN>.info;
location '/.well-known/acme-challenge' {
root /srv/www/<MY_ROOT_DIRECTORY>;
}
location / {
proxy_pass http://localhost:4200;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /secure {
auth_pam "Secure zone";
auth_pam_service_name "nginx";
}
}
为了验证,我使用了以下 certbot 命令:
certbot certonly --agree-tos --email <My_EMAIL>@gmail.com --webroot -w /srv/www/<ROOT_FOLDER>/ -d <DOMAIN>.info
certbot报错如下:
Performing the following challenges:
http-01 challenge for <MYDOMAIN>.info
Using the webroot path /srv/www/<ROOT_FOLDER> for all unmatched domains.
Waiting for verification...
Challenge failed for domain <MYDOMAIN>.info
http-01 challenge for <MYDOMAIN>.info
Cleaning up challenges
Some challenges have failed.
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain: <MYDOMAIN>.info
Type: unauthorized
Detail: Invalid response from
http://<MYDOMAIN>.info/.well-known/acme-challenge/Yb3c1WtCn5G43YatrhVorTbT_nn3WKTLwKjr0c9dW8E
[74.208.<...>.<...>]: "<!DOCTYPE html>\n<html
lang=\"en\">\n<head>\n<meta
charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot
GET /.well-known/"
在这一点上我真的一无所知。所有目录和文件对所有用户和组都具有读取权限。任何建议将不胜感激。
编辑
由于 Nginx 无法传递挑战文件,我修改了我的快速服务器以发送文件。快速应用程序是可访问的,并且很容易发送挑战文件以使certbot 工作。虽然不是理想的解决方案,但它确实有效。但是,我会保持帖子开放以获得更好的答案。
【问题讨论】:
-
你试过不加引号吗?
location /.well-known/acme-challenge { ... } -
@RichardSmith 我确实做到了。有效。我还遇到了其他一些问题,所有这些问题总结起来真的很混乱。主要问题是我忘记在我的 conf 文件中添加 .conf 扩展名。它没有被包括在内,并且 systemctl 状态显示 nginx 正在运行。直到我探测端口并发现 nginx 没有在 443 和 80 上运行并意识到我的错误。
-
我走上了同样的道路,但还没有开始工作。我认为正在发生的事情是 certbot 正在放置一个本地文件,然后尝试从 Web 服务器获取它。我不明白的是如何知道 certbot 将文件放在哪里。你有它作为 /srv/www/
;我有 /srv 但没有目录 /srv/www,我应该期望 certbot 将令牌放在哪里? -
@Don,您可以创建一个 www 目录并尝试在其中创建其他目录并将文件放在那里。另请注意,允许读取权限,以便网络服务器可以访问该文件。您可以通过浏览器访问您的站点
<site>.<tld>/.well-known/acme-challenge/<challenge-file>进行测试,如果可行,则 cerbot 挑战将成功通过。另外,请确保端口 443 已打开。希望对您有所帮助。 -
啊,我以为 certbox 会即时生成文件,看起来我可以在手动模式下运行它并获取我需要的文件,然后设置它并再次运行 certbox。我试图同步 certbox 将文件放在某个地方和 nginx conf 一起工作。
标签: nginx lets-encrypt certbot