Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 403
Sai Rahul Akarapu Avatar asked Oct 20 '25 14:10

Sai Rahul Akarapu


2 Answers

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

like image 51
Saikiran Avatar answered Oct 22 '25 03:10

Saikiran


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

.ebextensions/nginx/nginx.conf
like image 41
gyc Avatar answered Oct 22 '25 04:10

gyc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!