Passing request directly to named location

Dayo nginx-forum at nginx.us
Fri Feb 11 13:08:40 MSK 2011


Hello all.

I currently have my php set up as so

[code]
...
	location ~ \..*/.*\.php$ {
		return 403;
	}
	location ~* ^.+\.php$ {
		try_files $uri/fail @proxy;
	}
	location @proxy {
		proxy pass etc
	}
	location
some-location-that-sometimes-needs-rewriting-in-apache-htaccess {
		try_files $uri $uri/ @proxy;
	}
...
[/code]

Is there a way where when a '.php' file is equested, I just pass the
request to the '@proxy' location.

Now I have to use '$uri/fail' (a location that will never be found) so
that it will fail and then go to the '@proxy' location.

I see the time spent determining that '$uri/fail' does not exist to be a
waste but I can't do 'try_files @proxy' directly.

An option at also works is ... 

[code]
...
	location ~* ^.+\.php$ {
		error_page 403 = @proxy;
		return 403;
	}
...
[/code]

Just wondering which is more efficient.

Thanks

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,174090,174090#msg-174090




More information about the nginx mailing list