gpt4 book ai didi

laravel - 在 Elastic Beanstalk 上使用 Nginx 在子域上配置 Laravel

转载 作者:行者123 更新时间:2023-12-05 07:04:11 24 4
gpt4 key购买 nike

我的 Laravel 应用程序在主域( https://www.example.comhttps://example.com )上本地和远程运行,但我的暂存环境不起作用。主页有效,但其他路由无效(我收到 504)。

我使用的nginx.conf如下:

location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
if ($http_x_forwarded_proto = 'http'){
return 301 https://$host$request_uri;
}
}

如何添加 https://staging.example.com到这个配置?

最佳答案

由于您使用的是 Amazon Linux 2 (AL2),这可以解释为什么未使用您的 nginx 配置文件。

具体来说,在 AL2 平台上,nginx 配置文件 should be set.platform/nginx/conf.d/ 中,而不是在 .ebextensions 中。 nginx 是在 AL1 中使用 .ebextentions 设置的,但在 AL2 中不是。

因此,您可以尝试使用以下内容创建文件 .platform/nginx/conf.d/myconf.conf:

location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
if ($http_x_forwarded_proto = 'http'){
return 301 https://$host$request_uri;
}
}

请注意,我无法验证 nginx 配置文件是否正确。这只是基于你的问题。它也可能有错误。

关于laravel - 在 Elastic Beanstalk 上使用 Nginx 在子域上配置 Laravel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63001287/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com