Rails 作为过滤反向代理
我想逐渐将应用程序从旧的 java 过渡到新的 Rails 应用程序。数据流看起来像
user -> browser -> new rails -> old java
这样,即,新的 Rails 应用程序将充当旧应用程序的反向代理,并且用户永远不会比原始应用程序更明智。
随着越来越多的功能迁移到 Rails 应用程序,Java 应用程序的使用将越来越少。
我熟悉用于从其他应用程序请求资源的 Net::HTTP 类,但大多数示例都过于简化,并且不利于转换。一个全功能的 gem 将能够
- 处理常见的 HTTP 动词
- 传递并保留 cookies
- 重写旧应用程序中的 HTML(例如,旧应用程序将具有 href="/something/foo.html",新应用程序将具有 “/newpath/bar.html”)
- 具有可配置的会话感知(在 java应用程序与rails会话,这样如果你删除rails会话, 它可以通过注销回调到 java 应用程序)
性能并不是一个大问题。
有这样的宝石的指示吗?它可能会被归类为某种反向代理、中间人、过滤器等
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 featured 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议不要在 Rails 本身中执行此操作,而是直接在您的网络服务器(例如 Apache)中执行此操作
我一直在致力于将 Java 网站迁移到 Ruby 的大型项目,并且为此目的一直使用 Apache mod_rewrite 和 mod_proxy 。
因此,流程是
在 Apache 本身内使用模块意味着我们不需要使用任何 Rails 堆栈(以及相关的 CPU/内存/线程)。它还使我们能够满足您的要求之一,以确保“用户永远不会比原始应用程序更明智”。
会话管理是唯一棘手的部分;我引入了 Java 和 Rails 应用程序都可以读取的 cookie,并使用 cookie 的存在来告诉 Ruby 或 Java 用户是否已登录。这样,Ruby 和 Java 就不需要尝试管理彼此的会话。
希望其中一些内容有帮助吗?
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
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?