【问题标题】:AWS config files for Elastic Beanstalk don't workElastic Beanstalk 的 AWS 配置文件不起作用
【发布时间】:2021-04-16 17:36:11
【问题描述】:

我有一个使用 .ebextensions 文件夹的弹性 beantalk 旧 django 项目设置。 这个旧项目包含许多文件,其中一些通过放置配置来更新 Apache 文件到以下位置:

/etc/httpd/conf.d/

例如,它会通过在 .ebextensions 配置文件之一中添加以下命令来添加 enable_mod_deflate.conf:

container_commands:
    01_setup_apache:
        # Setup gzip compression on apache server by copying enable_deflate.conf into appropriate directory.
        command: "cp .ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf"

同样有一个缓存配置文件,看起来像这样:

files:
    "/etc/httpd/conf.d/enable_cache.conf":
        mode: "000444"
        owner: root
        group: root
        content: |
            <IfModule mod_expires.c>
                ExpiresActive on
                ExpiresDefault "access plus 1 day"
                ExpiresByType image/jpg "access plus 1 month"
                ExpiresByType image/jpeg "access plus 1 month"
                ExpiresByType image/gif "access plus 1 month"
                ExpiresByType image/png "access plus 1 month"
                ExpiresByType text/css "access plus 1 month"
                ExpiresByType text/javascript "access plus 1 month”
                ExpiresByType application/javascript "access plus 1 month”
                ExpiresByType image/ico "access plus 1 month"
                ExpiresByType text/html "access plus 600 seconds"
            </IfModule>

我遇到的问题是我刚刚尝试创建另一个 Django 项目。当我 ssh 进入旧的 ec2 实例(我使用的是单实例弹性 beanstalk 环境)时,我可以看到 /etc/httpd/conf.d/ 目录中的所有文件。但是,当我使用新的弹性 beanstalk 环境并查看 /etc/httpd/conf.d 目录时,没有创建任何配置文件。

它几乎就像 AWS 已经改变了弹性 beanstalk,使其无法复制到 conf.d 目录。

我已经下载了日志,但找不到任何可以解释副本停止工作的原因。

我设置原始 Django 项目是一年多前,所以我可能对此有误,但它有一个选择 nginx 作为服务器的选项,所以我不得不专门选择 Apache。感觉好像发生了一些变化。

有人知道为什么这不起作用以及我能做些什么吗?

【问题讨论】:

  • 你能给我们看一些相关的日志吗?

标签: django amazon-web-services apache amazon-elastic-beanstalk


【解决方案1】:

您正在使用基于 Amazon Linux 1 (AL1) 的 httpd ("/etc/httpd/conf.d/enable_cache.conf) 配置文件。但是,对于 EB 基于 AL2 的平台,代理 httpd 的设置与 AL1 上的设置不同。具体来说,它们应该在.plaftorm 文件夹中,而不是.ebextentions。来自docs

配置文件位置 – 您应该将代理配置文件放在所有 Amazon Linux 2 平台版本的 .platform/nginx 和 .platform/httpd 目录中。

关于如何在 AL2 平台上设置 httpd 的更多详细信息,请参见 Configuring Apache HTTPD

【讨论】:

    猜你喜欢
    • 2021-11-24
    • 2021-02-01
    • 2013-04-11
    • 2015-02-18
    • 2018-12-29
    • 2016-08-02
    • 2019-12-02
    • 2018-04-20
    • 2015-04-23
    相关资源
    最近更新 更多