How to use EC2 as a web proxy

If KRON Channel 4 or KICU gave me the ability to stream A's games, I'd gladly pay for it, but they don't, and we're not going to pay for cable just to get baseball.

MLB.tv is great and they allow you to stream games, but they have blackout restrictions where you can't stream the game if it's also being shown on cable locally.

Fortunately, there's a workaround. Because MLB.tv filters based on IP address, you can get around the restriction by sending your Internet traffic through a proxy computer, with an IP address that isn't blocked (this is how, for example, people in China get on the internet). Most proxies are slow though and become unwatchable if you try to stream a high-bandwidth video. If only you could use a high-bandwidth proxy and not share it with anyone else...

Fortunately Amazon provides servers in the cloud that let you do exactly this. People usually use them for running web servers, but you can use them for this purpose just as easily.

  1. Go to aws.amazon.com and login using your Amazon credentials. They will ask you for your credit card and to verify your phone number. As long as you stay inside the Free Tier (roughly 30-40 games a month) you will not be charged.

  2. Click on EC2. Click "Create Instance," then use the Quick Launch wizard. Create an Ubuntu instance (one of the "Free Tier eligible" ones) and make sure you download the credentials, as you need them to log in and they won't be available later.

  3. On the next page click on "Edit Details," then on "Security Settings." You need to create a new Security Group, that will allow computers from your apartment to connect to your new computer in the cloud. Find your apartment's IP address by visiting http://jsonip.com. Then fill out the details like this:

    EC2 Security Group Settings

    Substitute in your own IP address. If you have a cool ISP like Sonic, you can get a static IP address, which makes this much easier. Otherwise your IP address may change from day-to-day, and you'll have to update this setting, or provide a broader range of valid IP addresses in the form.

  4. You need one other piece of information which is the hostname for your EC2 instance. It will look something like this: ec2-12-34-56-789.compute-1.amazonaws.com.

  5. Now the fun parts! Open up the Terminal and type in:

    ssh -i $HOME/.ssh/mlb.pem ubuntu@ec2-12-34-56-789.compute-1.amazonaws.com -D 2001
    

    where $HOME/.ssh/mlb.pem is the route to the .pem file you downloaded earlier, and the hostname is the hostname you got above. Go ahead and leave this connection open. You need to leave this open while you're trying to watch some baseball.

    (This won't work for PC users. If you're on a PC you have to configure PuTTY to use SSH, which is an unusable mess that I'm glad I don't have to deal with anymore).

  6. Now open Firefox Preferences, click "Advanced", click "Settings", then type in these settings:

    Firefox proxy settings

    To check that they were applied correctly, visit jsonip.com in your Firefox browser. It should be a different IP than your apartment! Browse away!

Some notes:

  • The next time you set this up, all you have to do is run the SSH command in your terminal, and set up Firefox to use the proxy. It won't hurt your computer to kill either at any time, but the stream will stop working.

  • This uses the free tier of Amazon Web Services; if you go over your limits then Amazon will charge you. You can check your usage in the "Account Activity" portal on aws.amazon.com.

  • I've only done this for one game, and the usage I checked was about 0.4 GB, which means with 15 GB in/out per month, you should be able to stream about 30 games, assuming no other usage. The connection between MLB and Amazon is really good; the connection between Amazon and your apartment may not be, depending on your connection speed.

  • It may be better to configure these settings in your router so everyone can connect. I'm not sure how to do that, however.

  • Again, I wish this weren't a problem but MLB blacks out games on their streaming service, so there's no way to stream games that are on cable. I have no problem paying for a stream, as we are in fact paying for MLB.tv. I'll take this post down once someone figures out how I can pay to stream games in my local market, without resorting to hacks like this.

9 thoughts on “How to use EC2 as a web proxy

  1. Ryan Cummins

    Thank you for posting this. Just want to point out a couple of things to other folks who might stumble upon this article…

    - PC users can install cygwin and OpenSSH to use the ssh command in step five.

    - You can disable your proxy and close out your SSH connection as soon as your video stream starts playing. This should help to avoid overage fees from Amazon.

    Thanks again. Great stuff!

    Reply
  2. Rick

    Chetan Surpur’s *Sidestep* is a handy tool that you could use for this as well. I think someone has gotten it to work with EC2 as well.

    Reply
  3. Jay

    Thanks for this. I spent a week trying to ssh into my EC2 and could not make it work, until I found your instructions. Great stuff.

    Reply
  4. Jay

    I have a small improvement to your suggestion:

    ssh -f -i -D 2001 -N

    -f Requests ssh to go to background just before command execution. This is useful if ssh is going to ask for passwords or passphrases, but the user wants it in the background.

    -N Do not execute a remote command. This is useful for just forwarding ports (protocol version 2 only).

    With -N, you don’t actually log into the EC2 server.

    Reply
  5. Jayson

    Looks to me like the MLB apps for web and Boxee aren’t working with the EC2 proxy anymore. I assume they are wise to this and are blocking EC2 IPs.

    Is there a particular instance location or other way to get around this?

    Reply
    1. kevin Post author

      I don’t know – I haven’t had any luck lately with EC2. Looks like MLB has gotten wise to this trick. :(

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>