4

I tried changing nginx config using

Attempt 1

.ebextensions/000_nginx.config

container_commands:
  01_reload_nginx:
    command: "sudo echo 'underscores_in_headers on;' >> /etc/nginx/conf.d/elasticbeanstalk/00_application.conf"

and

Attempt 2

.ebextensions/000_nginx.config

files:
  "/tmp/proxy.conf":
    mode: "000644"
    owner: root
    group: root
    content: |

      underscores_in_headers on;
container_commands:
  00-add-config:
    command: cat /tmp/proxy.conf >> /etc/nginx/conf.d/elasticbeanstalk/00_application.conf
  01-restart-nginx:
    command: /sbin/service nginx restart

and

Attempt 3

.ebextensions/nginx/conf.d/elasticbeanstalk/00_application.conf

location / {
    proxy_pass          http://127.0.0.1:5000;
    proxy_http_version  1.1;

    proxy_set_header    Connection          $connection_upgrade;
    proxy_set_header    Upgrade             $http_upgrade;
    proxy_set_header    Host                $host;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
}

underscores_in_headers on;

But each try updates files and then clears out the changes after code deploy to Beanstalk

How can I prevent overwriting config files or basically how to change Nginx config?

2 Answers2

1

In the archive you upload to EBS, you should be able to override the nginx conf inside

.ebextensions/nginx/nginx.conf
gyc
  • 4,300
  • 5
  • 32
  • 54
  • Still same issue – Sai Rahul Akarapu Sep 12 '18 at 06:55
  • @SaiRahulAkarapu apparently this works for java and go platforms. What are you using? Docker? – gyc Sep 12 '18 at 07:06
  • This method does not seems to work for Docker platform. I had to follow this method: https://stackoverflow.com/questions/24860426/nginx-config-file-overwritten-during-elastic-beanstalk-deployment/46900753 – Sofien May 27 '20 at 14:18
1

I had a similar issue before. It might be because you are zipping and uploading the whole project folder instead of just the project folder contents

Saikiran
  • 756
  • 2
  • 11
  • 29