try_files issue

Igor Sysoev is at rambler-co.ru
Sat Feb 14 13:35:40 MSK 2009


On Fri, Feb 13, 2009 at 11:38:02PM +0100, Xavier Grangier wrote:

> >- 	try_files $document_root/$uroot @django;
> >+ 	try_files /$uroot @django;
> 
> works well thanks for your answer.
> finally the probleme is on the dynamic build of $croot for exemple :
> 
> location /users/ {
> 	#set $croot cache/1/1/1/fr.html;
> 	## match /users/1/fr/xxxx/
> 	if ($request_uri ~ /([0-9])/(\w+)/[-\w]+/$) {
> 		set $croot cache/$1/$1/$1/$2.html;
> 		set $deb 2;
> 	}
> 	sub_filter nginx '$croot - $uri - $deb';
> 	try_files $croot @django;
> }
> 
> returns a 403 forbidden. wether the cache file exists or not.
> With sub filter I can see that : nginx is well replace by 'cache/1/1/1/ 
> fr.html - /users/1/fr/xxxx/ - 2' so all variables are set.
> 
> if I do set $croot like this (same value as before)
> 
> location /users/ {
> 	set $croot cache/1/1/1/fr.html;
> 	try_files $croot @django;
> }
> 
> it works as expected. cache is served if exists or backend is called.
> 
> Where do I mixed up ?

This is because I unfortunately did not thoroughly think over "if" blocks
inside nginx. Currently "if" block has it own configuration that inherits
directives from previous level. The try_files is not inherited, so it
does not work inside "if".


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list