1

I've a Django application that is running on EC2 instance. It is uploading file upto 100MB without any problems, but above 100MB file size, it gives error 413 Request Entity Too Large.

I've tried in file /etc/nginx/sites-available/default under server configuration.

client_max_body_size 10G;

I've also applied the same configuration in my domain configuration files, but all in vein. This configuration works well in my other servers, where I am running php applications.

Note: I've used gunicorn with supervisor for running Django application.

shantanu sharma
  • 55
  • 2
  • 11

3 Answers3

1

The client_max_body_size has to be defined in both http and https as stated in this answer.

So your nginx.conf file under /etc/nginx/sites-available/default would look something like:

http {
    server {
        ...
        listen       80;
        server_name  xxxx.net;
        client_max_body_size 10G;
    }

    server {
        ...
        listen       443 default_server ssl;
        server_name  xxxx.net;
        client_max_body_size 10G;
    }
}
Helge Schneider
  • 483
  • 5
  • 8
0

@Helge thanks, I've applied the configuration parameters in both of them.

The issue is resolved now. The issue was, initially it was throwing error due to configuration parameter defined below other parameters, after resolving that Cloudflare started throwing 413 error. So, my team lead made configuration changes for the same.

shantanu sharma
  • 55
  • 2
  • 11
0

in you 01__django.config add files: "/etc/nginx/conf.d/proxy.conf" : mode: "000755" owner: root group: root content: | client_max_body_size 20M; #use These or go to the your root via ssh pass the commands

  1. cd ..
  2. cd .. now use : sudo nano /etc/nginx/nginx.conf add : client_max_body_size 20M; # these will add 20mb of size to your request body Now Reload Your NGINX Server using nginx -s restart