Search code examples
djangonginxamazon-ec2gunicornsupervisord

How to increase file upload size in Django application running on EC2 instance with Nginx as revese Proxy?


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.


Solution

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