reverse_proxy (mod_rewrite) and rails

Posted by SooDesuNe on Server Fault See other posts from Server Fault or by SooDesuNe
Published on 2010-12-30T22:53:10Z Indexed on 2010/12/30 22:55 UTC
Read the original article Hit count: 216

I have front end rails app, that reverse proxies to any of a number of backend rails apps depending on URL, for example

http://www.my_host.com/app_one reverse proxies to http://www.remote_host_running_app_one.com

such that a URL like http://www.my_host.com/app_one/users will display the contents of http://www.remote_host_running_app_one.com/users

I have a large, and ever expanding number of backends, so they can not be explicitly listed anywhere other than a database. This is no problem for mod_rewrite using a prg:/ rewrite map reverse proxy.

The question is, the urls returned by rails helpers have the form /controller/action making them absolute to the root. This is a problem for the page served by mod_rewrite because links on the proxied page appear as absolute to the domain. i.e.:

http://www.my_host.com/app_one/controller/action has links that end up looking like /controller/action/ when they need to look like /app_one/controller/action

Is there a way to fix this server-side, so that the links will be routed correctly?

© Server Fault or respective owner

Related posts about apache

Related posts about mod-rewrite