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
demandé il y a 3 ans658 vues
1 réponse
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
répondu il y a 3 ans

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions