【发布时间】:2021-02-23 12:55:32
【问题描述】:
我在单独的容器中运行 NGINX、PHP-FPM 和 DB。
PHP-FPM 内部正在从我的本地机器上安装一个 Laravel 项目。
在访问 127.0.0.1:8000 时,我已成功将 PHP 请求转发到 PHP-FPM 容器(端口 9000)。不幸的是,带有资产扩展名(例如 .css、.js)的请求已遇到 403 禁止。
以下是我的 NGINX 配置脚本。
server {
listen 80;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index 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 fpm:9000;
fastcgi_param SCRIPT_FILENAME /app/public$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
location ~* \.(css|js|gif|ico|jpeg|jpg|png)$ {
fastcgi_pass fpm:9000;
fastcgi_param SCRIPT_FILENAME /app/public$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
}
不确定是否有人遇到过类似的问题并有解决方案?
【问题讨论】:
-
您能否为任何 403 请求添加带有完整响应标头列表的屏幕截图?
-
@IvanShatsky 按要求添加。