partial urlEncoding when using if and $request_uri

Maxim Dounin mdounin at mdounin.ru
Mon Nov 11 17:33:41 UTC 2013


Hello!

On Mon, Nov 11, 2013 at 11:35:34AM -0500, mte03 wrote:

> Hi, 
> 
> I can confirm that using named variables solves the issue (as stated in the
> ticket - maybe you can add my findings (rewrite log) to the ticket comments,
> as I have no rights to do so). Both 

You actually have rights to do so (though some login is required).  
But as the ticket already shows how to reproduce the problem, I 
don't think linking a rewrite log will be beneficial.

> if ($request_uri ~ ^/[^\/]+(?<match>/.*)$ ) { set $patch $match; }
> and
> if ($request_uri ~ ^/[^\/]+(?<path>/.*)$ ) { set $match abc; }
> 
> do work correctly. However, from the performance standpoint, is this
> solution with IF faster (or more recommended) than doing st. like
> 
> map $request_uri $path {
>   ~^/[^\/]+(?<param>/.*)$ $param;
> }
> 
> Is there any way to further improve performance on this kind of matching?

I don't think there is a measurable performance difference.  Use 
of map{} might be a bit better as it doesn't involve if(), see 
http://wiki.nginx.org/IfIsEvil.

-- 
Maxim Dounin
http://nginx.org/en/donation.html



More information about the nginx mailing list