File uploads and client_max_body_size in nginx + gunicorn + django

Posted by carlosescri on Server Fault See other posts from Server Fault or by carlosescri
Published on 2013-06-11T12:08:36Z Indexed on 2014/06/09 9:27 UTC
Read the original article Hit count: 275

Filed under:
|
|
|

I need to configure nginx + gunicorn to be able to upload files greater than the default max size in both servers.

My nginx .conf file looks like this:

server {
    # ...

    location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect   off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme  $scheme;
        proxy_connect_timeout 60;
        proxy_pass http://localhost:8000/;
    }
}

The idea is to allow requests of 20M for two locations:

  • /admin/path/to/upload?param=value
  • /installer/other/path/to/upload?param=value

I've tried to add location directives at the same level than the one I've pasted here (getting 404 errors) and also tried to add them inside the location / directive (getting 413 Entity Too Large errors).

My location directives look like these in their simplest form:

location /admin/path/to/upload/ {
    client_max_body_size 20M;
}
location /installer/other/path/to/upload/ {
    client_max_body_size 20M;
}

But they don't work (actually I tested lots of combinations and I'm desperate thinking about this.

Please, help If you can: What settings do I need to set to make this work?

Thank you so much!

© Server Fault or respective owner

Related posts about nginx

Related posts about django