Multiple client_max_body_size (location based)

Juan Fco. Giordana juangiordana at gmail.com
Tue Jan 13 14:14:28 MSK 2009


Thank you very much Igor,

It seems that I forgot something while doing the combinations :)

I have another question that is more or less related to this subject 
too: Is there a way to avoid entering over and over the fastcgi 
parammeters?, this would be excluding the usage of the include directive 
since the effect would be the same as typing everything.

server {
     [...]
     client_max_body_size 1m;
     [...]

     location ~ \.php$ {
         try_files $uri @sitename;

         fastcgi_pass  127.0.0.1:9000;
         fastcgi_index index.php;
         fastcgi_param SCRIPT_FILENAME /path/to/www/$fastcgi_script_name;
         include fastcgi_params;
     }

     location = /upload-file.php {
         client_max_body_size 15m;
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_param SCRIPT_FILENAME /path/to/www/$fastcgi_script_name;
         include fastcgi_params;
     }

     location = /upload-image.php {
         client_max_body_size 2m;
         fastcgi_pass 127.0.0.1:9000;
         fastcgi_param SCRIPT_FILENAME /path/to/www/$fastcgi_script_name;
         include fastcgi_params;
     }

     location @sitename {
         # Avoid Link Rot.
         rewrite ^/aboutus\.php$       /about/ permanent;
         rewrite ^/activate\.php$      /signup/activate/ permanent;
         rewrite ^/something\.php$     /else/ permanent;

         fastcgi_pass 127.0.0.1:9000;
         fastcgi_param SCRIPT_FILENAME /path/to/www/rewrite.php;
         include fastcgi_params;
     }
}

Thanks again.

Igor Sysoev wrote:
> Yes, it's possible, however, you should correct your locations:
> 
> -     location = upload-image.php {
> +     location = /upload-image.php {
> 
> 





More information about the nginx mailing list