1

I am working on a deploying a docker image through CodePipeline to Elastic Beanstalk that is using an Elastic Load Balancer.

I have the following file structure:

  • .ebextensions
    • nginx
      • conf.d
        • elasticbeanstalk
          • nginx-config.conf

Inside the file is modifications such as:

 sendfile        on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   10;
        types_hash_max_size 2048;
        client_body_buffer_size 2000M;

I noticed my configurations were not sticking. When I connect to the instance created by elasticbeanstalk, my /etc/nginx/conf.d/elasticbeanstalk/ does not contain any of the configuration files.

My questions are: 1) Whys is my .ebextensions being ignored? 2) Is there another way of modifying the nginx config?

Btw, both my Dockerrun.aws.json and buildspec.yml are executing.

Mark B
  • 183,023
  • 24
  • 297
  • 295
Devin Dixon
  • 11,553
  • 24
  • 86
  • 167
  • I’m currently experiencing the same. I tried both approaches creating a .conf through a yaml config file in `.ebextensions` and directly placing an nginx .conf file in `.ebextensions/nginx/conf.d`. Neither led to the expected result. Then I kept an eye on the `conf.d` folder during deployment: my .conf file was actually created but the whole `conf.d` folder gets recreated at a later stage of the deployment _after_ the .conf has been placed there. The config changes simply are deleted and not ignored. No clue how to work around this though. – Oliver Aug 21 '20 at 09:44

2 Answers2

0

For anyone that might run across the same issue, here is how I solved it...Custom Built AMI.

  1. Go to EC2 and create an instance
  2. In the Community AMI tab, look for one that is elasticbeanstalk nginx 3 Launch the instance and modify it to your needs
  3. Stop the instance
  4. Create An Image from the stopped instance
  5. Put the ami in the Elastic Beanstalk configuration section where it asks for capacity.

A gotcha to watchout over. DO NOT try to make any changes to /etc/nginx/nginx.conf. EBS will automatically overwrite anything you put in there. Instead put all modificatins in /etc/nginx/conf.d/somefile.conf that will override anything in /etc/nginx/nginx.conf.

Devin Dixon
  • 11,553
  • 24
  • 86
  • 167
0

After working without any success through different solutions to this issue that have been posted on Stackoverflow in the course of the last years (like this), I tried to find out where the data conf.d is overwritten with actually comes from. And I found the folder /var/proxy/staging/nginx/conf.d/. I tested it and copied my custom nginx conf file into the folder. And it worked. So you can achieve changes to the nginx config on the instances of your multi-container Docker setup on Beanstalk like this:

# .ebextensions/00_nginx.config

files:
  "/tmp/custom.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
      client_max_body_size 20M;

container_commands:
  01_copy_conf:
    command: "sudo cp /tmp/custom.conf /var/proxy/staging/nginx/conf.d/00_custom.conf"

As nginx is reloaded anyways when the whole conf.d is replaced in /etc/nginx, there is no need for a reload here.

Oliver
  • 507
  • 6
  • 12