php - Laravel 在使用 NginX 配置的所有路由上返回 404
问题描述
我一直在尝试解决这个问题一天。我检查了所有类似的问题并做了同样的事情,但这似乎不起作用。
我目前正在服务器上运行一个节点 JS 应用程序,现在我打算将 laravel 添加到它。但是所有路由都返回 laravel 404 错误页面。
这是配置文件。
server {
listen 80;
listen [::]:80 ipv6only=on default_server;
root /var/www/html/dlabs.cloud-File-Service/public;
index index.html index.htm index.php;
server_name dlabs.com.ng;
location /auth/ {
proxy_pass http://localhost:3000;
proxy_pass_header Server;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /file-service/ {
try_files $uri $uri/ /index.php?$query_string;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
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.3-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
expires 5d;
}
# deny access to . files, for security
#
location ~ /\. {
log_not_found off;
deny all;
}
}
PHP 版本是 7.3 版。
/auth/ 完美运行。
解决方案
添加try_files $uri $uri/ /index.php$is_args$args;
到 nginx.conf
在 => /etc/nginx/nginx.conf
推荐阅读
- google-cloud-platform - Dataflow Flex 模板作业已排队
- python-3.x - Python中的Countif函数在每个单元格中循环
- wso2 - 如何在 WSO2 中打开和编辑 JAR 包?
- python - Django“'str'对象没有属性'decode'”错误
- plsql - 如何在 DBeaver/DBVisualizer 中编写 DB2 pl/sql 脚本
- nginx - Kubernetes Ingress 未正确找到/公开应用程序
- amazon-web-services - 如何获取具有特定模式的aws存储桶上的文件列表
- javascript - 设置双精度数组值
- php - 如何发送/接收在我的网站 booknow.html 页面上输入的信息到电子邮件或其他方法
- javascript - Discord.js 在尝试将游戏消息转换为不和谐消息时给我留下“TypeError:无法读取未定义的属性'包含'”