Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

345
Views
Elastic Beanstalk: `.ebextensions` not getting executed

I'm deploying a PHP application to Beanstalk and all appears to be fine, however my .ebextensions configuration files don't seem to be running.

I have just a single configuration file that is supposed to create a file, and then reload nginx.
/my-project/.ebextensions/nginx.config:

files:
  "/etc/nginx/conf.d/elasticbeanstalk/extend-nginx.conf" :
    mode: "000755"
    owner: root
    group: root
    content: |
      add_header X-Frame-Options "SAMEORIGIN";
      add_header X-XSS-Protection "1; mode=block";
      add_header X-Content-Type-Options "nosniff";

      location / {
          try_files $uri $uri/ /index.php?$query_string;
      }

container_commands:
    reload_nginx:
        command: "sudo service nginx reload"

My architecture is currently:
1. CodePipeline hooked up to GitHub that deploys the app to CodeDeploy everytime master is updated.
2. CodeDeploy receives the deployment from CodePipeline.
3. CodeDeploy installs it to the Elastic Beanstalk instance.

All the above steps work fine. I just don't understand why the config file in .ebextensions is not creating the file as expected.

Note: I have confirmed that the .ebextensions folder is in the root of the revision .zip by manually downloading one of the revisions and checking.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

For me I was confused why a file I was trying to create was not showing up when I was deploying. The deployment had an error, and the system would automatically delete the file due to the error instead of letting it persist while rolling back to it's previous state on failure. This gave me the false notion that the file was never created in the first place.

I was able to determine this from /var/log/nginx/error.log which gave the following:

2020/07/29 20:11:36 [emerg] 23006#0: "gzip" directive is duplicate in /var/proxy/staging/nginx/conf.d/elasticbeanstalk/gzip.conf:1

which meant at least for me, I needed to override nginx.conf instead of adding a configuration file. Make sure that you aren't getting errors with your deployment if you're not seeing a file get created.

over 4 years ago · Santiago Trujillo Report

0

Try to simply put this file into .ebextensions/nginx/conf.d/elasticbeanstalk without a script.

At least this is how the Java SE platform works: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-nginx.html. I don't think this is different for PHP.

Also on your EC2 instace check the output of log files (cfn-init.log, cfn-init-cmd.log etc.).

over 4 years ago · Santiago Trujillo Report

0

Can I refer you to the following link which describes the official way to configure the nginx reverse proxy on EB environments:

[1] Configuring the proxy server - https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/nodejs-platform-proxy.html

Another option is to use 'sed' like command to update the nginx configuration in place, as follows:

container_commands:
    enable_websockets:
        command: |
            sed -i '/\s*proxy_set_header\s*Connection/c \
                    proxy_set_header Upgrade $http_upgrade;\
                    proxy_set_header Connection "upgrade";\
            ' /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!