[英]Configure Laravel on a subdomain with Nginx on Elastic Beanstalk
My Laravel application runs locally and remotely on the main domain ( https://www.example.com and https://example.com ), but my staging environment doesn't work. My Laravel application runs locally and remotely on the main domain ( https://www.example.com and https://example.com ), but my staging environment doesn't work. The main page works, but other routes don't (I get a 504).
主页有效,但其他路线无效(我得到 504)。
The nginx.conf I use is the following:我使用的 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;
}
}
How do I add https://staging.example.com to this configuration?如何将https://staging.example.com添加到此配置?
Since you are using Amazon Linux 2 (AL2), this could explain why your nginx config file is not used.由于您使用的是 Amazon Linux 2 (AL2),这可以解释为什么不使用您的 nginx 配置文件。
Specifically, on AL2 platforms, nginx config files should be set in .platform/nginx/conf.d/
, not in .ebextensions
.具体来说,在 AL2 平台上,nginx 配置文件应设置在
.platform/nginx/conf.d/
中,而不是.ebextensions
中。 The nginx were setup using .ebextentions
in AL1, but not in AL2. .ebextentions
设置,但在 AL2 中没有。
Thus, you could try creating file .platform/nginx/conf.d/myconf.conf
with the content:因此,您可以尝试使用以下内容创建文件
.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;
}
}
Please note, I can't verify whether the nginx config file is correct.请注意,我无法验证 nginx 配置文件是否正确。 It's just based on your question.
这只是基于你的问题。 It could also have mistakes.
它也可能有错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.