Hi, I have found similar topics on discussion with location based
request but because I’m using a PHP software that by default handles
everything through a single PHP file (including processing POST uploads
of files) I would like to be able to use
if ($request_uri ~* upload$) {
client_max_body_size 200M;
}
for example, so that all URI with the word upload at the end will
automatically get set a larger client_max_body_size.
But given that the above syntax is currently impossible. How would I be
able to achieve the same result?
The way my nginx conf works is via:
upstream php {
server unix:/php.sock;
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
location ~ .php$ {
fastcgi_pass php;
include fastcgi_params;
}
Hi, I have found similar topics on discussion with location based
request but because I’m using a PHP software that by default handles
everything through a single PHP file (including processing POST uploads
of files) I would like to be able to use
if ($request_uri ~* upload$) {
client_max_body_size 200M;
}
On Saturday 28 January 2012 14:52:38 skyroski wrote:
Hi, I have found similar topics on discussion with location based
request but because I’m using a PHP software that by default handles
everything through a single PHP file (including processing POST uploads
of files) I would like to be able to use
if ($request_uri ~* upload$) {
client_max_body_size 200M;
}
If you want something like “if ($uri …” then you should use the
“location”
directive:
internal;
All the rest I didn’t have to change with the exception of adding an
extra clause to the location .php$ block to restore PHP_VALUE to
default settings.
I understand around-abouts why IF is evil but if it’s supposed to be
safe for rewrites and return then I’d rather take advantage of that
instead of using location / with try files so that I can deal with query
strings attachments easier and it ends up shorter to implement.
All the rest I didn’t have to change with the exception of adding an
extra clause to the location .php$ block to restore PHP_VALUE to
default settings.
I understand around-abouts why IF is evil but if it’s supposed to be
safe for rewrites and return then I’d rather take advantage of that
instead of using location / with try files so that I can deal with query
strings attachments easier and it ends up shorter to implement.
@Valentin’s solution would have meant I had to maintain 3 different
fastcgi_pass php location blocks as one would also be required for
location ~ upload$ {.
Thanks for all the hints and tips.
Posted at Nginx Forum:
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.