Sai Rahul Akarapu
Sai Rahul Akarapu

Reputation: 307

Nginx config overwrites during beanstalk deployment

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?

Upvotes: 4

Views: 755

Answers (2)

Saikiran
Saikiran

Reputation: 776

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

Upvotes: 1

gyc
gyc

Reputation: 4360

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

.ebextensions/nginx/nginx.conf

Upvotes: 1

Related Questions