Home > OS >  How to increase file upload size in Django application running on EC2 instance with Nginx as revese
How to increase file upload size in Django application running on EC2 instance with Nginx as revese

Time:03-02

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.

CodePudding user response:

@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.

CodePudding user response:

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;
    }
}
  • Related