Elastic Beanstalk – Ebextension config file not showing on ec2 instance

files:
  "/home/ec2-user/vhost.conf":
    mode: "000777"
    owner: root
    group: root
    encoding: plain
    content: |
      NameVirtualHost *:80

      <VirtualHost *:80>
        ServerName api.domain.com
        DocumentRoot "/var/app/current/api/"
        <Directory "/var/app/current/api">
          AllowOverride All
          Require all Granted
        </Directory>
      </VirtualHost>

container_commands:
  00_chmod:
    command: "sudo chmod 777 /etc/httpd/conf.d/elasticbeanstalk"
  01_rewrite:
    command: "sudo mv -f /home/ec2-user/vhost.conf /etc/httpd/conf.d/elasticbeanstalk/vhost.conf"
  02_apache:
    command: "sudo apachectl restart"

This is the config i am using, i got it looking for solutions to my issue, now ino there is questions to this but the asnwers are outdated and don;t work, the config runs correctly i can confirm in the logs that the command are been ran with no error, but when i ssh into the ec2 there is no conf file in the directory, i assuming eb is removing them after deployment.

anyone any idea whats going on ? the aws docs are next to useless.

>Solution :

The changes to http must be done using .platform/httpd/conf.d, not regular .ebextentions. The details and examples are in AWS docs under "Configuring Apache HTTPD":

To extend the Elastic Beanstalk default Apache configuration, add .conf configuration files to a folder named .platform/httpd/conf.d in your application source bundle.

Leave a Reply