character escaping in proxy pass question

Larrytheliquid larrytheliquid at gmail.com
Fri May 2 17:14:57 MSD 2008


Is there a way to use "proxy_pass" without having it unescape the characters
in the uri?

For example, using the following configuration:

        location /my_proxy/ {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_redirect off;

            proxy_pass http://my_proxy/;
        }

A request to "/my_proxy/sites/http%3A%2F%2Fwww%2eexample%2ecom" will arrive
to the my_proxy server as "/sites/http://www.example.com", instead of
"sites/http%3A%2F%2Fwww%2eexample%2ecom".

You can get the raw format by removing the slash at the end of the
proxy_pass:

        location /my_proxy/ {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_redirect off;

            proxy_pass http://my_proxy;
        }

Now, a request to "/my_proxy/sites/http%3A%2F%2Fwww%2eexample%2ecom" will
arrive to the my_proxy server as
"my_proxy/sites/http%3A%2F%2Fwww%2eexample%2ecom", instead of
"sites/http%3A%2F%2Fwww%2eexample%2ecom".
I would like "my_proxy" would to gone but the rest of the uri to remain
escaped.

I've tried manually rewriting like so:

        location /my_proxy/ {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_redirect off;

            rewrite      /my_proxy/(.*)  /$1  break;
            proxy_pass http://my_proxy;
        }

However, this results in the same behavior as the first example (where the
unescaping still occurs.)

-- 
Respectfully,
Larry Diehl
www.larrytheliquid.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20080502/af25a489/attachment.html>


More information about the nginx mailing list