我有一个基于 Beanstalk (Amazon Linux 2) 构建的 Spring Boot 应用程序,我需要增加 client_max_body_size,因为我发布的某些表单数据包含图像,并且我收到了
413: Request Too Large
Nginx 错误。
我按照 AWS 的文档了解如何更改此属性。
我的项目结构现在看起来像这样:
文件内容为:
client_max_body_size 50M;
部署后,我不断收到相同的错误(图像总数> 1MB)。
conf.d 中尚未创建文件:
这是因为我的
buildSpec
如何打包我的应用程序吗?
version: 0.2
phases:
install:
runtime-versions:
java: corretto17
pre_build:
commands:
- echo Nothing to do in the pre_build phase...
build:
commands:
- echo Build started on `date`
- mvn package -Dmaven.test.skip
post_build:
commands:
- echo Build completed on `date`
artifacts:
files:
- .platform/nginx/conf.d/proxy.conf
- target/myApp-0.0.1-SNAPSHOT.jar
- appspec.yml
discard-paths: yes
我还尝试将配置文件添加到我的
artifacts.files
的 buildspec.yml
部分。
我还尝试从构建规范的
files
部分创建文件及其内容。
我觉得我已经尝试了一切,有什么我可能遗漏的吗?
目前,我的解决方法
我手动编辑了文件:
cd /etc/nginx/
sudo nano nginx.conf
并重新启动。这有效,但我想避免这种手动配置,因此它是从应用程序源配置的,这是一个很好的做法。
问题出在我的构建规范上。
discard-paths: yes
将所有文件放在捆绑包的根路径上。我需要这个,所以我的罐子位于根部,但它也将
proxy.conf
放在根部。
将该属性设置为 no(或删除它)使其可以工作,但我需要一种方法将 jar 从 /target/ 更改为根目录,因此我使用构建后命令来完成此操作:
version: 0.2
phases:
install:
runtime-versions:
java: corretto17
pre_build:
commands:
- echo Nothing to do in the pre_build phase...
build:
commands:
- echo Build started on `date`
- mvn package -Dmaven.test.skip
post_build:
commands:
- mv target/myApp-0.0.1-SNAPSHOT.jar myApp-0.0.1-SNAPSHOT.jar <------ HERE
- echo Build completed on `date`
artifacts:
files:
- .platform/nginx/conf.d/proxy.conf
- myApp-0.0.1-SNAPSHOT.jar
- appspec.yml