启用第2个nginx块时遇到一些麻烦-无法使域指向正确的根文件夹,而“让我们加密Acme”挑战失败了(可能是相关问题)。
该服务器为Ubuntu 18.04,我将其用作在站点上工作的沙箱。
这是刚刚重定向到nginx默认页面的站点的可用站点conf
server {
root /var/www/boothslop.online;
index index.php index.html index.htm index.nginx-debian.html
servername boothslop.online www.boothslop.online;
location = /favicon.ico { lognotfound off; accesslog off; }
location = /robots.txt { lognotfound off; accesslog off; allow all; }
location ~* .(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
lognotfound off;
}
location / {
#tryfiles $uri $uri/ =404;
tryfiles $uri $uri/ /index.php$isargs$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
这是该站点的可用站点配置,它们可以正常工作,以便在访问域时可以加密并查找正确的根文件夹。
server {
root /var/www/webtest.tech;
index index.php index.html index.htm index.nginx-debian.html
servername webtest.tech www.webtest.tech;
location = /favicon.ico { lognotfound off; accesslog off; }
location = /robots.txt { lognotfound off; accesslog off; allow all; }
location ~* .(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
lognotfound off;
}
location / {
#tryfiles $uri $uri/ =404;
tryfiles $uri $uri/ /index.php$isargs$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/webtest.tech/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/webtest.tech/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.webtest.tech) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = webtest.tech) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name webtest.tech www.webtest.tech;
}
这是我从Acme挑战中遇到的错误
Domain: www.boothslop.online
Type: unauthorized
Detail: Invalid response from
http://www.boothslop.online/.well-known/acme-challenge/G13Ou7X8U-KMQVvT_ExNvAfK5cF-jHkobGp7hyqw8ac
[192.34.60.43]: "<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>"
非常感谢!
答案 0 :(得分:0)
错误404 Not Found
表示找不到以下文件:
您是否已将所述文件添加到公共目录中?
在应对极致挑战时,系统会要求您在该地址中添加一个文本文件以及内容,以便可以进行验证
再次运行命令,它将要求您保存具有确定的文件名和内容的文件。按照以下结构创建文件夹:
<public directory>
- .well-known
- acme-challenge
将文本文件添加到acme文件夹中,然后继续进行验证。
希望有帮助!