0

I have a ruby Sinatra server set up, which looks like this:

     require 'sinatra'
     require 'rest-client'

     url = "http://youtube.com"

     get '/youtube' do
        RestClient.get(url)
     end

This approach seems to work fine when the page is visited by a computer which is on a network where the URL, in this case youtube.com, is NOT blocked. When I run visit the page while connected to a network which blocks sites like youtube, the website style is different (bland) and very few images on the page load (including video).

How can this be fixed, so that when the site it visited on a restricted network, youtube displays as usual?

Cj1m
  • 805
  • 3
  • 11
  • 26
  • 2
    You'd have to modify the page you're proxying to point all of it's script, image and other links to your proxy as well. And any links inside those scripts too. Otherwise just passing the content along it will still point to their servers in many places. You'll also need to handle these new requests, relative to your `/youtube` sinatra path. – Nick Veys Jun 20 '14 at 18:40

1 Answers1

0

That won't work. You must respond to all the YouTube urls and clients must set your machine as a proxy.

Here is an example of proxy in ruby

https://gist.github.com/torsten/74107

To make your code work you would need to read YouTube page content and replace all blocked urls with yours which doesn't seem practical.

Ismael Abreu
  • 16,443
  • 6
  • 61
  • 75