proxy_pass to URL encoded path?

7zark7 nginx-forum at nginx.us
Sat May 8 04:06:21 MSD 2010


Hi,

I'm using proxy_pass in front of CouchDB, which has file paths which contain some URL encoded characters (e.g. http://couch:5984/images[b]%2F[/b]logo.gif)

I am trying to to replace some characters in requests to nginx with the URL-encoded equivalent:

http://localhost/images/logo.gif -> http://couch:5984/images[b]%2F[/b]logo.gif


My attempt was this:

[code]
rewrite  ^/images/(.*)$  /images%2F$1 break;

location ^~ /images {
       proxy_pass   http://couch:5984;
}
[/code]


However, it looks like proxy_pass is double-encoding the % character, which results in the following CouchDB request:

'GET' /images[b]%252F[/b]logo.gif


How might I do the following rewrite?:

http://localhost/images/logo.gif -> http://couch:5984/images%2Flogo.gif


Thanks

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




More information about the nginx mailing list