在 Amazon AWS Elastic Beanstalk 中设置子域

Har*_*rry 5 amazon-ec2 amazon-ebs amazon-web-services

我正在尝试在 Amazon 的 Elastic Beanstalk 中设置一个应用程序,并且我想为该应用程序的一部分使用一个子域。理想情况下,该子域将映射到文档根目录中的文件夹(即:http : //test.mydomain.com从 /var/www/html/test 中提取源)。我可以在 Route 53 中为子域设置另一个别名记录,但如何映射 Apache?

我能想到的唯一方法是直接通过 SSH 连接到服务器,将 VirtualHost 条目添加到我的 httpd.conf,然后将该服务器滚动到 AMI 并跨 EBS 重新部署。这是唯一的选择吗?(似乎必须有更简单的方法)

谢谢!

小智 20

试试下面的链接。

在 .ebextensions 目录中的根目录中添加一个配置文件。

然后加上这个。

files:
  "/etc/httpd/conf.d/vhost.conf":
    mode: "000644"
    owner: root
    group: root
    encoding: plain
    content: |
      NameVirtualHost *:80

      <VirtualHost *:80>
        DocumentRoot "/var/app/current/"
         <Directory "/var/app/current/">
          Options Indexes FollowSymLinks MultiViews
          AllowOverride All
          Require all granted
         </Directory>
      </VirtualHost>

      <VirtualHost *:80>
       ServerName your-custom-domain-here.com
       DocumentRoot "/var/app/current/your-new-webroot"
        <Directory "/var/app/current/your-new-webroot">
         Options Indexes FollowSymLinks MultiViews
         AllowOverride All
         Require all granted
        </Directory>
      </VirtualHost> 
Run Code Online (Sandbox Code Playgroud)

更多信息在这里:

http://blog.celingest.com/en/2013/04/05/elastic-beanstalk-cloudflare-newrelic-virtualhost-2/

  • 这是正确答案... (2认同)

jam*_*ieb 0

这对于 Elastic Beanstalk 来说是不可能的(至少在没有真正滥用它的情况下是不可能的)。Elastic Beanstalk 是“即发即忘”类型的 PaaS 解决方案,旨在实现简单部署。如果您确实需要此类功能,请查看CloudFormation,它可以让您更精细地配置实例配置。