开发者

Rails as a filtering reverse proxy

I'd like to gradually transition an app from old java to a new rails app. The data flow would look like

user -> browser -> new rails -> old java

That is, the new rails app would function as a reverse proxy to the old app, and the user would never be the wiser of the original app.

As more functionality is migrated to the rails app, the java app would become used less and less.

I'm familiar with the Net::HTTP classes for requesting resources from the other app, but most examples are overly simplified, and don't facilitate the transition. A full feature开发者_如何学God gem would be able to

  • handle common HTTP verbs
  • pass and retain cookies
  • rewrite HTML from the old app (for instance, the old app will have href="/something/foo.html", and the new app would have "/newpath/bar.html")
  • have configurable session awareness (associate a sessionID on the java app with the rails session, such that if you delete the rails session, it could callback to the java app with a logout)

Performance is not a big concern.

Any pointers to such a gem? It would probably be classified as some sort of reverse proxy, man -in-the-middle, filter, etc


I would suggest not doing this in Rails itself, but rather doing it in directly in your webserver (e.g. Apache)

I have been working on a large project to migrate a Java website to Ruby, and have been using Apache mod_rewrite and mod_proxy for this purpose.

So the flow was

    user -> browser -> apache -> passenger or Tomcat

Using modules within Apache itself meant that we did not need to use any of the Rails stack (and associated CPU/memory/threads). It also allowed us to meet one of your requirements to ensure that "the user would never be the wiser of the original app"

Session management is the only tricky part to this; I introduced a cookie that the Java and Rails app could both read, and used the presence of the cookie to tell Ruby or Java if the user was logged in. This way, Ruby and Java did not need to try to manage each other's sessions.

Hope some of that proves helpful?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜