我无法让 nginx 返回我放入的文件/var/www/letsencrypt
。
nginx/sites-available/mydomain.conf
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name my-real-domain.com;
include /etc/nginx/snippets/letsencrypt.conf;
root /var/www/mydomain;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
nginx/snippets/letsencrypt.conf
location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
root /var/www/letsencrypt;
}
我运行这个命令: certbot certonly --webroot -w /var/www/letsencrypt/ -d my-real-domain.com
但是 certbot 尝试访问的页面始终是 404。
调试
$ echo hi > /var/www/letsencrypt/hi
$ chmod 644 /var/www/letsencrypt/hi
现在我应该可以了curl localhost/.well-known/acme-challenge/hi
,但这不起作用。仍然是 404。知道我错过了什么吗?