WAR中忽略了Elastic Beanstalk .ebextensions [英] Elastic Beanstalk .ebextensions ignored in WAR

查看:117
本文介绍了WAR中忽略了Elastic Beanstalk .ebextensions的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图更改我的Elastic Beanstalk NGINX反向代理的 client_max_body_size 属性,以允许上传较大的JPEG文件。因此,我将文件夹 .ebextensions添加到我的WAR文件的根目录中(WAR文件还包括Spring Boot应用程序),并添加了具有以下内容的文件 .ebextensions / 01_files.config:

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;

我通过Travis-CI将WAR文件部署到Elastic Beanstalk。但是,似乎文件被Elastic Beanstalk忽略了,因为上传的文件大小为2MB不起作用,当通过SSH连接到实例并查找 /etc/nginx/conf.d/proxy.conf时,该文件不存在。

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.

我已经使用YAML验证程序成功验证了上述内容。我知道,存在很多相关问题,但似乎没有一个能解决我的问题。我还检查了根目录中的WAR文件中是否包含 .ebextensions / 01_files.config。当我检查 / tmp / eb_extracted_jar时,文件 .ebextensions / 01_files.config也存在正确的内容。我什至在 /var/log/cfn-init.log中找不到任何错误。我注意到,仅在几秒钟内,文件 proxy.conf在部署期间出现在 /etc/nginx/conf.d/中,但随后被删除了。

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.

由于通过Travis-CI部署到Elastic Beanstalk会发生此问题吗?还是我错过了其他重要的事情?

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

编辑:
我刚刚认识到,当应用程序每次创建几秒钟时都会创建 proxy.conf文件部署,但几秒钟后消失(已在 /etc/nginx/conf.d/中用 ls -lsa 检查,请参见13:34的时间戳记 elasticbeanstalk目录和 healthd_http.conf, proxy.conf为13:43)

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

几秒钟后 ls -lsa / etc / nginx / conf.d /:

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


推荐答案

阅读文档数小时后,我发现我错过了Elastic Beanstalk Java SE平台的AWS官方文档中的一些重要内容(请参阅 http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-platform.html )。

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. 绝对是我的错误:我使用了错误的文件扩展名,文件夹 .ebextensions中的文件扩展名必须为 .conf,但不是。config。

至少对于Java SE平台:可以直接在 .ebextensions目录中添加NGINX配置文件,而无需使用 files:...生成具有特定内容的文件的语法,即在 /etc/nginx/conf.d/proxy.conf中创建代理文件,只需在内容中添加 .ebextension / nginx / conf.d / proxy.conf client_max_body_size 20M; 直接。随后, proxy.conf将被部署到 /etc/nginx/conf.d/proxy.conf,并自动包含在默认的NGINX配置中。

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.

这篇关于WAR中忽略了Elastic Beanstalk .ebextensions的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆