Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elastic Beanstalk .ebextensions ignored in WAR

I am trying to change the client_max_body_size property of my Elastic Beanstalk NGINX reverse-proxy in order to allow uploads for larger JPEG files. Therefore, I added the folder ".ebextensions" to the root directory of my WAR file (the WAR file is also including a Spring Boot application) and added a file ".ebextensions/01_files.config" with the following content:

files:
  "/etc/nginx/conf.d/proxy.conf" :
    mode: "000755"
    owner: root
    group: root
    content: |
        client_max_body_size 20M;

I deploy the WAR file via Travis-CI to Elastic Beanstalk. However, it seems that the file is beeing ignored by Elastic Beanstalk since uploads with a filesize e.g. 2MB do not work and when connecting with SSH to the instance and looking for "/etc/nginx/conf.d/proxy.conf" the file does not exist.

I already successfully validated above content with an YAML validator. I know, there exists plenty of related questions but non of those seem to fix my problem. I also checked if ".ebextensions/01_files.config" is included in the WAR file in root directory. And when I check "/tmp/eb_extracted_jar", the file ".ebextensions/01_files.config" also exists with the correct content. I can't even find any errors in the "/var/log/cfn-init.log". I noticed that, just for some seconds, the file "proxy.conf" appeared in "/etc/nginx/conf.d/" during deployment but then it has been removed.

Can this problem occure because of the deployment to Elastic Beanstalk via Travis-CI? Or did I miss something else that is important?

EDIT: I just recognized that the "proxy.conf" file is created every time for a few seconds when the application is deployed but after a few seconds it disappears (checked with ls -lsa in "/etc/nginx/conf.d/", see the timestamps with 13:34 for "elasticbeanstalk" directory and "healthd_http.conf" and 13:43 for "proxy.conf")

4 drwxr-xr-x 3 root root 4096  6. Dec 13:43 .
4 drwxr-xr-x 4 root root 4096  6. Dec 13:34 ..
4 drwxr-xr-x 2 root root 4096  6. Dec 13:34 elasticbeanstalk
4 -rw-r--r-- 1 root root  148  6. Dec 13:34 healthd_http.conf
4 -rwxr-xr-x 1 root root   26  6. Dec 13:43 proxy.conf

And after a few seconds ls -lsa "/etc/nginx/conf.d/":

4 drwxr-xr-x 3 root root 4096  6. Dec 13:44 .
4 drwxr-xr-x 4 root root 4096  6. Dec 13:44 ..
4 drwxr-xr-x 2 root root 4096  6. Dec 13:44 elasticbeanstalk
4 -rw-r--r-- 1 root root  148  6. Dec 13:44 healthd_http.conf
like image 526
Tom Avatar asked Dec 06 '16 11:12

Tom


1 Answers

After hours of reading docs, I found out that I missed some important parts of the official AWS docs for the Elastic Beanstalk Java SE Platform (see http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-platform.html).

  1. Definitely my mistake: I used the wrong file extension, the file extension in the folder ".ebextensions" has to be ".conf" but not ".config".

  2. At least for the Java SE Platform: one can directly add NGINX config files within the ".ebextensions" directory without using the "files: ..." syntax to generate a file with a specific content, i.e. to create the proxy file in "/etc/nginx/conf.d/proxy.conf" just add ".ebextension/nginx/conf.d/proxy.conf" with the content client_max_body_size 20M; directly. Subsequently, "proxy.conf" will then be deployed to "/etc/nginx/conf.d/proxy.conf" and automatically included by the default NGINX config.

Hope this answer saves someone else the time it took me to figure that out.

like image 150
Tom Avatar answered Sep 21 '22 21:09

Tom