Search code examples
.netamazon-web-servicesnginxamazon-elastic-beanstalk.net-5

.Net 5 AWS nginx Linux elastic beanstalk changing client_max_body_size


I am unable to upload a file above 1 megabyte due to the default setting on AWS elastic beanstalk nginx. I have looked online and I have found out that I need to change the client_max_body_size to client_max_body_size 20M to allow for larger files. However, there is no where for me to do this. There is no Nginx config file on .net. I am using .net 5 and I then use aws toolkit on visual studio 19 to upload it to elastic beanstalk. the only config file that I can see is the aws-beanstalk-tools-defaults.json.

{
 "region" : "eu-west-2",
 "configuration" : "Release",
 "framework"     : "net5.0",
 "self-contained" : false,
 "application"    : "testapplication",
 "environment"    : "testapplication-prod-env",
 "enable-xray"    : false,
 "enhanced-health-type" : "basic",
 "additional-options"   : "",
 "proxy-server"         : "nginx",
 "solution-stack"       : "64bit Amazon Linux 2 v2.1.5 running .NET Core",
 "environment-type"     : "LoadBalanced",
 "cname"                : "vitradssltest-prod",
 "instance-type"        : "t3a.nano",
 "key-pair"             : "my key pair for testing",
 "instance-profile"     : "aws-elasticbeanstalk-ec2-role",
 "service-role"         : "aws-elasticbeanstalk-service-role",
 "loadbalancer-type"    : "classic",
 "health-check-url"     : "/"
}

01_nginx.config'

file location


Solution

  • Since you are using 64bit Amazon Linux 2 v2.1.5 running .NET Core nginx is on by default. Thus, I don't see any reason why standard way of customizing nginx wouldn't work for you.

    Specifically, the custom settings should be in .platform/nginx/conf.d/ as shown in the docs. Therefore, you can create the following .platform/nginx/conf.d/myconfig.conf file with the content:

    client_max_body_size 20M;