Use of ProxyPassReverse to change Location response header

apache-2.2httpmod-proxymod-rewriteruby-on-rails

I am implementing a reverse http proxy:

proxy.example.com

This will forward requests to servers based on URI:

proxy.example.com/server1 -> server1.example.com

When a user requests proxy.example.com/server1, server1 sends a programatically generated (Ruby Devise Gem) 302 response with the following "Location" value:

proxy.example.com/users/sign_in

I need this to be:

proxy.example.com/server1/users/sign_in

I have implemented the following config in Apache:

ProxyPass "/server1/" "http://server1.example.com/"
ProxyPassReverse "/server1/" "http://server1.example.com/"

as per:

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypassreverse

"This directive lets Apache adjust the URL in the Location, Content-Location and URI headers on HTTP redirect responses. This is essential when Apache is used as a reverse proxy (or gateway) to avoid bypassing the reverse proxy because of HTTP redirects on the backend servers which stay behind the reverse proxy."

But the Location header that is being returned by server1 is still:

proxy.example.com/users/sign_in

Is there something wrong with my config?

thx

Best Answer

Figured it out:

ProxyPass "/server1/" "http://server1.example.com/"
ProxyPassReverse "/server1/" "http://proxy.example.com/"