Laravel 在 AWS 上使用 SSL - 404 Not Found 错误

Laravel on AWS with SSL - 404 Not Found errors

我有一个 laravel 项目,我正在尝试 运行 在 AWS Elasticbeanstalk 上 - 我上传了该项目并使用 HTTP 100% 工作,当我上传确切的内容时,客户决定他们需要 SSL相同的源代码,我的登录页面完美运行 (https://sitename/),但是任何其他页面(例如 https://sitename/login 根本无法运行,并且我收到 404 Not Found 错误消息。

我的输出如下(我将除最后一部分以外的 ip 地址清零以提供上下文):

2022/05/25 03:51:46 [error] 7872#7872: *21072 open() "/var/www/html/public/login" failed (2: No such file or directory), client: 000.00.00.164, server: , request: "GET /login HTTP/1.1", host: "00.000.000.113"
2022/05/25 03:57:03 [error] 7871#7871: *21210 open() "/var/www/html/public/_debugbar/assets/javascript" failed (2: No such file or directory), client: 000.00.00.164, server: , request: "GET /_debugbar/assets/javascript?v=1644364352 HTTP/1.1", host: "portal.sitename", referrer: "https://portal.sitename/"
2022/05/25 03:57:03 [error] 7872#7872: *21209 open() "/var/www/html/public/_debugbar/assets/stylesheets" failed (2: No such file or directory), client: 000.00.00.164, server: , request: "GET /_debugbar/assets/stylesheets?v=1644364352&theme=auto HTTP/1.1", host: "portal.sitename", referrer: "https://portal.sitename/"
2022/05/25 04:01:26 [error] 7872#7872: *21313 open() "/var/www/html/public/ReportServer" failed (2: No such file or directory), client: 000.00.00.193, server: , request: "GET /ReportServer HTTP/1.1", host: "13.244.47.136"
2022/05/25 04:01:39 [error] 7872#7872: *21320 open() "/var/www/html/public/ReportServer" failed (2: No such file or directory), client: 000.00.00.164, server: , request: "GET /ReportServer HTTP/1.1", host: "00.000.000.113"
2022/05/25 04:08:15 [error] 7872#7872: *21477 open() "/var/www/html/public/login" failed (2: No such file or directory), client: 000.00.00.193, server: , request: "POST /login HTTP/1.1", host: "portal.sitename", referrer: "https://portal.sitename/"

documentation available laravel 与 beantalk 结合使用。

您的问题是网络服务器在错误的目录中搜索文件造成的。您是否选择 PHP 作为平台?您是否已将文档根目录设置为 /public?

发生这种情况是因为您的服务器不接受 url 中的查询字符串。为了解决这个问题,您应该添加另一个名为 .platform 的文件夹,然后按照下面的 laravel.conf 文件中的文本进行操作。这将是固定的 确保您使用 nginx 作为来自 elastic benstalk 配置的服务器

.platform configuration

laravel.conf 文件

location / {
    try_files $uri $uri/ /index.php?$query_string;
    gzip_static on;
}

感谢大家的协助,对于所有关注此问题的人,我所做的就是解决:

cd  /etc/nginx/conf.d/elasticbeanstalk
nano laravel.conf

添加了以下代码:

location / { 
try_files $uri $uri/ /index.php?$query_string; 
}