英文:
Nginx Error 413 Entity too large on AWS ELB
问题
So,我正在使用Django作为我的后端应用程序,部署在AWS Elastic Beanstalk(EC2 t2.micro,Amazon Linux 2)上。当我尝试提交明显大于1MB的文件(.mp4、pdf)时,我收到Nginx错误413:实体过大。问题在于,无论我尝试什么,都会在几个小时后被重置为默认配置。据我所了解,有一个自动扩展功能,在每次新部署后都会重置一切,有时甚至在没有部署的情况下也会发生重置。我知道很多人都面临过这种问题,对于其中一些人,其他帖子中描述的操作可以解决问题。然而,对于我来说,一切要么立即在部署后重置,要么在几个小时后重置。
我已经尝试了在Stackoverflow的其他帖子中建议的方法,包括在EC2控制台中更改nginx文件、在源代码中添加自己的配置文件(.ebextensions文件夹)、对我的S3存储桶进行了一些更改,以及许多其他选项。
***注意:我还为Django自身创建了一个处理大文件的自定义函数,但我认为它与我收到的Nginx错误无关。
我的.ebextensions目录:
--.ebextenstions
--nginx
--conf.d
--proxy.conf
--02_files.config
proxy.conf的内容:
client_max_body_size 100M;
02_files.config的内容:
files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 100M;`
谢谢。
英文:
So,I am using Django for my backend application deployed on AWS Elastic Beanstalk (EC2 t2.micro, Amazon Linux 2). When I am trying to submit files (.mp4, pdf) that are obviously larger than 1MB, I get Nginx Error 413: Entity too large. The problem is that everything I have tried works for a few hours, before everything is getting reset to the default configurations. As far as I understood there is an auto-scaling functionality that resets everything after each new deploy and sometimes even without deploy.I know that a lot of people had faced this kind of problem, and for some of them actions described in other posts solved the problem. However, for me everything resets either immediately after deploy, or in a couple of hours.
I have already tried, as suggested in other posts on Stackoverflow, changing the nginx file from the EC2 console, adding my own configuration file in source code (.ebextensions folder), applied some changes to my S3 bucket, and many other options.
***NOTE: I have also created a custom function for handling large files in Django itself, but I think it is irrelevant to the Nginx error that I get.
My .ebextensions directory:
--.ebextenstions
--nginx
--conf.d
--proxy.conf
--02_files.config
Content of the proxy.conf:
client_max_body_size 100M;
Content of 02_files.config:
`files:
"/etc/nginx/conf.d/proxy.conf" :
mode: "000755"
owner: root
group: root
content: |
client_max_body_size 100M;`
Thanks.
答案1
得分: 1
对于 Amazon Linux 2
,您需要使用 .platform
,而不是 .ebextentions
。因此,请创建一个文件,例如 myconfig.conf
(.platform/nginx/conf.d/myconfig.conf
),其内容如下:
client_max_body_size 100M;
英文:
For Amazon Linux 2
you have to use .platform
, not .ebextentions
. So create a file, e.g. myconfig.conf
(.platform/nginx/conf.d/myconfig.conf
) with content of:
client_max_body_size 100M;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论