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

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

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.

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

Leave a comment