2

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!

2 Answers 2

5

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; } } 
2
  • client_max_body_size 0M; will remove size restrictions Commented Nov 19, 2015 at 6:42
  • Thank you for the answer :-) Will be useful for other people. Commented Nov 20, 2015 at 12:51
0

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?

1
  • 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. Commented Jun 12, 2013 at 13:42

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.