Nginx - Laravel - LEMP - 访问除 / 以外的任何页面时出现 403 禁止错误
Nginx - Laravel - LEMP - getting 403 Forbidden error when accessing any page other than /
刚刚创建了一个 Laravel 7 应用程序并将其传输到我的新数字海洋水滴。我安装了 LEMP 及其工作所需的一切。
然而,当我转到服务器 IP 并访问主页“/”时,none 正在加载资产(图像、css、javascript)。如果我转到应用程序的任何其他页面,我会收到错误 403 Forbidden。
Nginx error.log shows a ton of these:
*47 access forbidden by rule, client: IP_ADDRESS(ive changed this to hide IP), server: IP_ADDRESS(ive changed this hide IP), request: "GET /images/logo.jpg HTTP/1.1", host: "138>2021/03/12 00:03:12 [error] 8059#8059:
我的 nginx 文件如下所示:
server {
listen 80;
server_name IP_ADDRESS; <------Changed this to hide IP
root /var/www/challenge/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / { try_files $uri $uri/ /index.php?$query_string; }
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ .php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.(?!well-known).* { deny all; }
}
有什么想法吗?
从您的配置中删除这一行:
location ~ /.(?!well-known).* { deny all; }
刚刚创建了一个 Laravel 7 应用程序并将其传输到我的新数字海洋水滴。我安装了 LEMP 及其工作所需的一切。
然而,当我转到服务器 IP 并访问主页“/”时,none 正在加载资产(图像、css、javascript)。如果我转到应用程序的任何其他页面,我会收到错误 403 Forbidden。
Nginx error.log shows a ton of these:
*47 access forbidden by rule, client: IP_ADDRESS(ive changed this to hide IP), server: IP_ADDRESS(ive changed this hide IP), request: "GET /images/logo.jpg HTTP/1.1", host: "138>2021/03/12 00:03:12 [error] 8059#8059:
我的 nginx 文件如下所示:
server {
listen 80;
server_name IP_ADDRESS; <------Changed this to hide IP
root /var/www/challenge/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / { try_files $uri $uri/ /index.php?$query_string; }
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ .php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.(?!well-known).* { deny all; }
}
有什么想法吗?
从您的配置中删除这一行:
location ~ /.(?!well-known).* { deny all; }