Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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!

share|improve this question

2 Answers 2

Sounds like it was almost working when you had the client_max_body_size in the non-root locations. Have you also set dav_methods PUT; in your nginx conf to enable PUT and DELETE requests?

share|improve this answer
    
Thank you for your answer @chrskly. The method used to upload the files is POST so I think there is no need for adding the dav_methods setting. Please, correct me if I'm wrong. –  carlosescri Jun 12 '13 at 13:42
up vote 0 down vote accepted

This finally worked doing something like this:

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_set_header X-Forwarded-Protocol ssl;
    proxy_connect_timeout 120;
    proxy_pass http://localhost:8000/;

    location /admin/path/to/upload {
        client_max_body_size 50m;
        proxy_pass http://localhost:8000/admin/path/to/upload;
    }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.