Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Rails act as a reverse proxy for hosting a domain on mysite?

I have mysite.com. Currently my blog is blog.mysite.com

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

Is it possible to use Rails as a reverse proxy that would main the URL structure at mysite.com/blog and show tumblr content, maintaining the mysite.com/blog url and article urls... Not redirecting to tumblr's URL?

Thanks

like image 205
Rachel D Roy Avatar asked Oct 22 '22 01:10

Rachel D Roy


1 Answers

Yes it is possible but a very heavy solution. What you need to do is define method on controller that would fetch the remote content and render 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 being said, you are much better off doing it using Nginx, HAProxy or other similar solutions

like image 144
Yuriy Goldshtrakh Avatar answered Oct 27 '22 00:10

Yuriy Goldshtrakh