开发者

Rails application as proxy for multiple rails applications

开发者 https://www.devze.com 2023-02-18 03:18 出处:网络
I have 开发者_Python百科multiple rails application running at a server. Each one at one port (ex: 8001, 8002, 8003, ...).

I have 开发者_Python百科multiple rails application running at a server. Each one at one port (ex: 8001, 8002, 8003, ...).

I would like to create another rails application that will act as a proxy to the others. The proxy rails app would run for example at port 8000 of domain www.example.com and, depending on requests do:

www.example.com:8000/app1 - pass the request to the app running at port 8001

www.example.com:8000/app2 - pass the request to the app running at port 8002

www.example.com:8000/app3 - pass the request to the app running at port 8003

I know this is possible with apache but in my case apache is not an option. Anyone knows how to do it?


You can make it in Application Controller or via yor routes.rb:

match "/:app", :to => redirect{ |params|
  case params[:app] 
  when "app1"
    "http://www.example.com:8001/"
  when "app2"
    "http://www.example.com:8002/"
  when "app3"
    "http://www.example.com:8003/"
  end
} 
0

精彩评论

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

关注公众号