gpt4 book ai didi

nginx - Nginx权限问题(404)

转载 作者:行者123 更新时间:2023-12-04 13:26:23 25 4
gpt4 key购买 nike

尝试让我们使用webroot方法对设置进行加密,该方法会创建并需要访问./.well-known/acme-challenge/目录中的文件。那里的所有内容(包括我添加的手动测试文件)都显示为404。

当我尝试以下方法的变体时,会变得疯狂:

location ~ /.well-known {
allow all;
}
location /.well-known/acme-challenge {
default_type text/plain;
}
location /.well-known {
try_files $uri $uri/ =404;
}

没有运气。我还检查了文件夹的权限,甚至将权限设置为777。我对设置nginx config很陌生,因此我确定有一个现有的情况会导致该问题:
server{
listen 80;
server_name domain.com www.domain.com;
location / {
rewrite ^(.*)$ https://domain.com$1 permanent;
}
location ~ /.well-known {
allow all;
}
}

server {
listen 0.0.0.0:443 ssl;
root /var/www/domain.com/public_html;
index index.php index.html index.htm;
server_name domain.com www.domain.com;
ssl on;
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
client_max_body_size 32m;
}
location ~ /.well-known {
allow all;
}
}

最佳答案

您的第一个server块需要一个root指令来解析本地文件。

有关更多信息,请参见this document

关于nginx - Nginx权限问题(404),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35668516/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com