Can Rails act as a reverse proxy to host a domain on mysite?

I have mysite.com. My blog is currently blog.mysite.com

I want my blog to be: mysite.com/blog - which would point to the tumblr blog.

Is it possible to use Rails as a reverse proxy that will be the main structure of the url at mysite.com/blog and display the contents of tumblr while supporting the mysite.com/blog url and article urls ... Do not redirect the url tumblr address?

thanks

+4
source share
1 answer

Yes, it is possible, but a very difficult decision. What you need to do is define a method on the controller that will retrieve the remote content and display it.

require 'net/http' class TunblrController<ApplicationController def index uri = URI('http://tumlbr.com/myblog') html = Net::HTTP.get(uri) render :html=>html end end 

that, as they say, you are much better off doing this with Nginx, HAProxy, or other similar solutions.

+2
source

Source: https://habr.com/ru/post/1447097/


All Articles