Unable to modify nginx config on CodeBuild deployment to EBS

2

We're using CodeBuild to automatically deploy to EBS. We need to modify nginx with a proxy.conf file containing:

client_max_body_size 20M;

to allow us to upload photos to S3. So far none of the documented methods to do this have worked. I initially attempted the following yaml content in .ebextensions/nginx_files.config:

files:
"/etc/nginx/conf.d/01_proxy.conf":
mode: "000644"
owner: root
group: root
content: |
client_max_body_size 20M;
container_commands:
01_nginx_reload:
command: “systemctl reload nginx”

This had no effect. After more research I discovered the new method for modifying the nginx config on Amazon Linux 2 is creating the conf file within the .platform directory. I tried using both these paths:

./platform/nginx/conf.d/00_proxy.conf
./platform/nginx/conf.d/elasticbeanstalk/00_proxy.conf

The 00_proxy.conf file is created on the EC2 instance in /var/app/staging, but is never copied to /etc/nginx/conf.d or /etc/nginx/conf.d/elasticbeanstalk. The next thing I tried was launching a script from Buildfile to copy the file into the correct place. I can see in /var/log/messages on the EC2 instance that Buildfile runs the script, but gets a permission denied message when attempting to copy. If I execute the cp command with sudo I get errors about needing a root password. How can I get around this permission issue?

jhester
posta 3 anni fa658 visualizzazioni
1 Risposta
2

I figured it out. I had to change discard-paths from yes to no in the CodeBuild Buildspec file and add a Procfile to the project that pointed to the full path of the jar file. The full .platform directory structure needs to remain intact for the nginx conf files to be able to end up in the correct location within the /etc/nginx directory. This is what I ended up with in the Buildspec file:

artifacts:
files:
- target/myapp.jar
- .ebextensions//*
- .platform/
/*
- Buildfile
- Procfile
discard-paths: no

jhester
con risposta 3 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande