簡體   English   中英

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

[英]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. 主頁有效,但其他路線無效(我得到 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 配置文件應設置.platform/nginx/conf.d/中,而不是.ebextensions中。 .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 配置文件是否正確。 這只是基於你的問題。 它也可能有錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM