I have a website build with Play! Framework that I show with NGinx using ssl.
Everything works fine but I'd like to implement a file upload limit based on url :
- If the user upload a file to */pages/** (/pages/ or /page/{id}/edit), I will limit the size to 10Mo (it will be zip archive)
- If the user upload a file to */images/** (/images/ or /images/{id}/edit), I will limit the size to 2Mo (it will be only images)
Here's where I'm stuck :
- I saw the
client_max_body_size
directive, that is exactly what I want, but do I have to specify for every location {}, the proxy_* configuration ? - I have a specific message to display if the user reach the quota allowed, in my app (located at /errors/413). If I go directly using my browser, it works. But using the configuration below, I've got a "504 Gateway Time-out". Why?
Here's my config file :
server {
listen 443;
server_name www.mywebsite.com;
access_log /var/log/nginx/mywebsite_access.log;
error_log /var/log/nginx/mywebsite_error.log;
ssl on;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/cert.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP:!kEDH;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:9010;
proxy_redirect off;
client_max_body_size 2m;
error_page 413 =200 /errors/413;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Ssl on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Thank you very much for your help ! :)