Rails: Proxy Pass

proxy, routes, ruby-on-rails

I've got a web-app that I want to migrate to Rails, which is currently just plain HTML with an Apache proxy to another server, running a custom database/webserver that serves the site's dynamic content.

For the moment, I want to do a staged move, since the content on the proxied server I won't be able to update until I update the static (HTML) server.

So… how would I configure a Rails route to proxy all requests to /dynamic/* to this other server? Or, how would I translate the Apache rule below to Rails?


Apache Proxy Rule:

ProxyPassMatch ^((?i)/dynamic/)(.*)$ http://xxx.xxx.com:8080/$2ProxyPassReverse /dynamic/ http://xxx.xxx.com:8080/

Best Solution

Rails routes are used to route some urls to one controller and one action.
You can't make a route to a distant URL or proxying like this.
And that wouldn't be a good idea as it would force us to load all rails (activerecord and everything) when it wouldn't be necessary at all. That's the opposite of scalability.

Using an Apache Proxy rule remains the most appropriate here.