nginx - NGINX 位置给出 404 错误,即使目录存在
问题描述
我的 NGINX 配置文件是这样设置的
root /var/www/html/tests_manager/webroot;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name qa.kloc.co.uk; # managed by Certbot
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
rewrite ^/uploads/(.*) /uploads/uploadsController.php last;
try_files $uri $uri/ =404;
}
location /support {
root /var/www/html/support-manager/webroot; #I have checked, this directory exists.
}
location = /notifications {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location = /supportSocket {
proxy_pass http://localhost:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
}
我希望该/support
位置重定向到不同的根目录,以便当用户尝试访问时,qa.kloc.co.uk/support
他们会在目录中看到该站点/var/www/html/support-manager/webroot
我的问题是,每当我尝试浏览此 URL 时,都会收到 404 错误。我检查了访问日志,但它们没有帮助。我只是看到
GET /support/index.php HTTP/1.1" 404 209
错误日志中没有任何内容。
我尝试使用重写(例如使用 /uploads/),但我认为我无法逃脱根目录。我也尝试使用location = /support
,location ^~ /support
但这些都没有效果。
我也尝试将/var/www/html/support-manager/webroot/
目录的所有者更改为,www-data
但这并没有什么不同。
请帮助我以正确的方式编写/支持位置
解决方案
推荐阅读
- typescript - 打字稿泛型作为对象键名
- mysql - 具有两个 IN 运算符的 SQL 查询,比较按索引执行
- c# - 如何在 Windows azure 虚拟机上挂载 azure 文件共享?
- heroku - 如何在 Heroku 上修复“包裹:权限被拒绝”
- c# - HotChocolate 将 UseFiltering 与 QueryType 中的解析器一起应用于字段
- kubernetes - 将 Cloud Tasks 与 GKE 服务结合使用
- angular - Angular:将 ngx-datatable 与 *ngFor 一起使用
- python - 如何在 pypy3 上运行 python 脚本而不使用 Windows 10 上的命令行?
- reactjs - 如何禁用 React 组件上的鼠标事件(echarts-for-react)?
- mysql - mysqldump 生成损坏的 sql 文件(显然在具有存储生成列的表上)(MySQL v8.0.21)