0

I deployed an ASP.NET Core Web App using AWS Elastic Beanstalk (in Visual Studio 2019, Windows 10). My App has an upload feature but it encounters a 413 Error (Request Entity Too Large) during Upload. I read that increasing the nginx client_max_body_size property will solve this issue.

Question: Is there a way to add this nginx configuration (client_max_body_size) in the appsettings.json or anywhere in the codebase specific to ASP.NET?

Update: I tried both solutions from this post (Both .ebextensions and .platform) Increasing client_max_body_size in Nginx conf on AWS Elastic Beanstalk

Folders Structure tried:

  • ~/ASP_Project_Folder/.ebextensions
  • ~/ASP_Project_Folder/.platform
  • Does this answer your question? [Increasing client\_max\_body\_size in Nginx conf on AWS Elastic Beanstalk](https://stackoverflow.com/questions/18908426/increasing-client-max-body-size-in-nginx-conf-on-aws-elastic-beanstalk) – Ermiya Eskandary Nov 08 '21 at 20:41
  • Welcome to Stack Overflow. So that you know why, I've voted to close this question as there seems to be already a duplicate of this question. Feel free to edit your question if the others don't work and you've tried the solutions suggested & add in what isn't exactly working. – Ermiya Eskandary Nov 08 '21 at 20:41
  • @ErmiyaEskandary I did try the answers from the post you referred but it didn't work. I updated my question and reopened it. Thanks – Dean Pinlac Nov 09 '21 at 23:07

1 Answers1

0

If you are using Visual Studio to publish the files, either via the standard dotnet publish command, or using the AWS toolkit integration, make sure that your project file is configured so the .platform folder is indeed copied to the output directory. Otherwise, it will simply be ignored and will not be part of the deployed package.

Make sure to add this to your .csproj file:

  <ItemGroup>
      <Content Include=".platform\nginx\conf.d\**">
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      </Content>
  </ItemGroup>

This will include any files within the ".platform\nginx\conf.d" directory and ship them as part of the deployment package.

I also had some issues with the file encoding of the .conf file which caused a fatal error upon deployment to AWS. The reason was that the .conf file was saved as UTF-8 with BOM. I had to open the file in Notepad and save it as UTF-8 (without BOM)

HaukurHaf
  • 13,522
  • 5
  • 44
  • 59