Getting rewritten and encoded/escaped url in nginx module

Maxim Dounin mdounin at
Wed Jun 4 15:04:59 UTC 2014


On Tue, Jun 03, 2014 at 02:08:36PM -0700, Jayadev C wrote:

> The problem is ngx_http_proxy doesn't do that either, once 
> rewrite is applied the url remains decoded (or I am not reading 
> the code correctly).

The proxy does ngx_escape_uri() if URI was rewritten.  It has to, 
as unencoded URI can't be used in a HTTP request.  Take a look at 
the ngx_http_proxy_create_request() function as previously 

> In fact escaping uri back is a bit tricky 
> since you have to split the rewritten url to segments and apply 
> encoding again (which would require looking at the original url 
> to know the correct number of '/'s).

As long as there were encoded slashes, the encoding of these 
slashes will be lost if URI was rewritten.  This is the expected 

Maxim Dounin

More information about the nginx mailing list