hulu

Update 2 (Oct 2009): Since this is reasonably popular content, here are some additional findings:

First, Flash does not always use the same settings as your browser - try the proxy settings in Internet Explorer/Chrome. These seem to work better. The vast majority of problems are a result of Flash using different settings than your browser, revealing your actual IP to Hulu.

Second, if this does not work you can always use Proxifier (commercial product with 30 days trial), a TCP wrapper which forces all connections on the computer to use a particular proxy. This can be used in conjunction with a Hulu downloader, such as Hulu Video Downloader to download the videos.

Update: Still works even after Hulu tightened their geofiltering. As long as one isn't using a mainstream service like Hotspot Shield, I doubt Hulu will be able to fully block this since they are in essence removing access from legitimate US computers. Probably the best thing would be to have a server set up in a legitimate, large institution such a US university or have a home-based server on a consumer ISP in the US. Both would make it hard to block the IP without causing legitimate users to be blocked as well. Then again, for me this is more of an interesting thing to do rather than a necessity. Mileage may vary depending on how proactive Hulu gets, in the end all anyone needs is one non-blocked legitimate IP address in the US.

If you haven't heard of Hulu, it's basically a website like YouTube but with full episodes of recent TV series - legal and with short commercials inserted into the video streams. For instance, the HBO show CSI is available on the site very soon after it has been shown in the US and you can watch it directly as streaming video. There is one caveat - the website blocks non-US viewers from watching any of the videos. So, no luck for us Finns.

However, this is rather easy to get around if you happen to have a server based in the US with SSH access. What you need to do is set up a SSH tunnel to your US server, then instruct your web browser to connect via that tunnel. This will cause all connections to Hulu to go through your US server, and will make it possible to watch Hulu videos.

Setting up using the SSH command/PuTTy

SSH allows you to connect securely to the server and create a secure tunnel from your computer to the US-based server. You can set up a local SSH client program to do this.

ssh -D 8080 -p 22 -f -N username@yourserver.com

As the SSH manual page states the -D option:

-D port. Specifies a local "dynamic" application-level port forwarding.
 This works by allocating a socket to listen to port on the local side, 
and whenever a connection is made to this port, the connection is
forwarded over the secure channel, and the application protocol is then
used to determine where to connect to from the remote machine.  Currently
the SOCKS4 and SOCKS5 protocols are supported, and ssh will act as a SOCKS server.

You can also do this in Windows using the PuTTy SSH client. Look under Connection -> SSH -> Tunnels. Add a dynamic port forward, use port 8080 and no need to specify the destination.

Setting Firefox to use the tunnel

Then set up Firefox to use the local SOCKS server (localhost:8080). The relevant settings can be found under Tools -> Options -> Advanced -> Network -> Settings ... -> Manual proxy configuration.

Testing

This works very nicely, because you are now connecting from an US IP. To verify this, open up Internet Explorer and check http://www.whatsmyip.org/ and do the same in Firefox. You should see two different IP addresses. Just remember that any videos you watch will be transferred twice (from a bandwidth usage perspective) - once to your US server and then back. A single video is only about a hundred megabytes or so, so this not particularly bad for the convinience though.

Comments

Mike: Am I missing a step?

I have generated a public and private key via Cpanel on my US server. I have followed the instructions to the T as above. Don't I have tell Putty what my keys are?

admin: That depends on whether you are using public key authentication or only password authentication (check sshd_config). I don't know about Cpanel, never used it, but I would first try connecting to the server via Putty. If your ssh daemon is configured to use public key authentication, then you will not be able to connect without a key.

If that works, then the next step would be set up the tunnel. Also, I recommend restarting your Firefox after changing the proxy settings or use the FoxyProxy addon - sometimes I have had odd glitches in applying the proxy settings in Firefox which went away when I used the addon.

Mike: Well, learned a lot about Putty and SSH in Cpanel today. So far I have Putty allowing me to login to my server using my private key via Jail Shell (host doesn't offer SSH).

Where I'm lost is the instructions:

Putty: Connection -> SSH -> Tunnels. Add a dynamic port forward, use port 8080 Firefox: Tools -> Options -> Advanced -> Network -> Settings … -> Manual proxy configuration

Instructions say to set the port to 8080. I tried that didn't work. The host has me using port 3765 so I tried that too.

Browser gives me error, and refuses to connect.

Is it Jail Shell messing with me here?

Mike: Sorry, didn't see your update here until I refreshed...will try your suggestions with Firefox next.

admin: When you try to access a site such as Google via your browser, if what you get is long wait then probably there is something wrong with the browser settings (try FoxyProxy). This means that the browser is accessing the tunnel but something is wrong.

If, however, you get a connection refused (or similar) error almost immediately, then check the SSH tunnel. You might have to wrong port, or restrictive firewall settings on your computer.

Also, since it seems you do not fully control your server (shared hosting?), there is the possibility that the AllowTcpForwarding setting is "no" for the ssh daemon, which means that tunneling is not allowed on the ssh daemon on the server - in which case you need to upgrade to something that allows you to configure your server fully.

Maccer: I'm sorry but I didn't get the Setting up Firefox to use the tunnel part. I don't know where to put localhost:8080. Please help me. I'm desperate.

admin: How to change proxy settings in Firefox 2.x and FireFox 3.x

http://it.usu.edu/htm/tutorials/firefox-proxy/

(Ignore the stuff about the password and so on, those obviously do not apply when using the tunnel.)

daniel: Sorry to be a kill-joy, but I'm pretty sure a SSH tunnel won't cut it, at least it doesn't for me. I assume that hulu uses UDP to provide the video thus making the SSH tunnel only viable for loading thumbnails and such, but not for the actual video streaming. I get the "unable to to stream this video " error despite being connected by a SSH tunnel through a US box. What we need is a way to tunnel (hulu specific) UDP traffic over the established SSH tunnel. A real VPN would always be the preferred way of course, but since most of the cheap virtual server hosts don't offer the necessary interfaces to build a VPN, we're left with SSH tunneling as the only viable option.

Any ideas here?

admin: Nope, still works. And Hulu does not seem to use UDP for watching videos, at least I am not seeing any additional packets coming in received while watching a video.

If you can see the site via your browser, and your browser IP is correct (US), then I can't think of other reasons than that Flash is not using the tunnel to connect - might be that Flash on Linux/Mac will not obey the proxy settings.

Of course it could also be that your server is blocked by Hulu or that different shows have different streaming mechanisms, although I doubt that either of these is the reason. I haven't tested this extensively, so mileage may vary.

Parneix: I have the same problem as Daniel : though I'm able to open a SSH tunnel giving me a US IP adress (and I know how to configure my network setting on a Mac to get both Safari and Forefox to use it) I still can't get anything from Hulu. I also tried this trick (see link), but still no success. Any idea? Thanks a lot for the article.

http://mattourne.blogspot.com/2009/01/watch-hulucom-outside-us-on-mac-os-x.html

P.

Parneix: The info I get from Proxifier while trying to connect to Hulu is the following. Maybe it could help someone to understand what's going on (and wrong) :

Error : The proxy server localhost:8080 has unexpectedly terminated the connection JavaApplicationS - Could not connect to 127.0.0.1:17747 through the proxy server

Thanks again.

P.

admin: I did a bit digging on this issue with OSX, and apparently Adobe Flash does not always obey the proxy settings set in the browser or the OS.

Have a look at this bug filed for Flash: http://bugs.adobe.com/jira/browse/FP-673

As for Parneix, you are clearly on the right track. What exactly is shown on your browser when you access Hulu versus some other site like google or whatsmyip? Screenshots?

I haven't used OSX but I suspect the problem is with Flash not obeying the proxy settings, it seems the proxy server at localhost:8080 is trying to connect to localhost (127.0.0.1) to get data, which is incorrect.

Anonymous: I'm not convinced this actually works.

I'm quite aware of SSH tunneling as a way to proxy a connection, I've used this technique for years on many OS's. I'm currently on a Vista machine and I'm having no luck with Hulu. That's actually why I'm still searching blogs for a working SSH tunnel solution.

I also assumed Flash was not respecting proxy settings, and it seems to be the case on my Windows machine. Are you sure you're not American and don't know it? :)

Anonymous: Use either HTTP SSL proxy (i.e. HTTP proxy with CONNECT option) or SOCKS proxy (e.g. SSH tunnel) and proxify browser through it using ProxyCap http://www.megaupload.com/?d=JA74JPR7 (ProxyCap works only on 32-bit Windows)

That's the only workaround for flash player bug.

Also you can use Transporter (which includes hack to remove ads...) + ProxyCap.

anon: Does the hulu video go through the tunnel such that anyone sniffing your packets cannot tell you are watching a video? Like at work.

Shon: Nope this wont work with Hulu anymore. Though it will work with some other sites such as Pandora or whatismyip.com

The reason it doesn't work with Hulu is mainly because Flash/RTMP does not respect the system / browsers proxy settings. The browser functions will work so Hulu won't flag you for being outside the US but when the browser tells flash to initiate the stream it fails with "Sorry we are unable to stream this video". Adobe does not consider this a problem. This is the same issue as a general SOCKS proxy will have.

To access Hulu you need a VPN solution that actually tunnels the traffic at the network layer. OR you could use some specific software to catch those RTMP requests and redirect them to a proxy. Foxyproxy has a software solution (video helper) for windows I believe. Though I'm on a mac so VPN it is.

Mike: I was able to get this working using Proxifier and a SSH tunnel through our Yankee server. Proxifier will route all network traffic through the tunnel, this includes Adobe flash.

Mike: Hulu is a no go.... I was able to connect to ABC.com, youtube.com (accessing restricted content) and fox.com

Tunneling: You can use the software from http://www.interwap.ro . They have free access at 384kbps and low prices for up to 50mbps high speeds.

Jay: UDP?? Do you understand what UDP is? Or better, why this would not work for streaming a video?

Lala: One key critical piece of missing information is that you need is block outgoing connections to a few of Hulu's servers on your local machine.

Flash attempts connections in the following manner:

  1. Try connecting directly to the server
  2. If that failed, try connecting through the proxy server specified in IE. If #1 succeeds, Flash would completely bypass your SSH tunnel and reveal your real IP to Hulu.

So you need to figure out the servers that Hulu us trying to connect to, and block them. To figure out the servers:

  1. Install "Live HTTP Headers" addon for Firefox and open it up
  2. Go to the Hulu video you want to watch
  3. In the Generator window, you will see a few urls that Hulu is hitting. The ones ending in /fcs/ident and /fcs/ident2 are interesting to us. They would be something like "hulufs.fplive.net" and "hulu-123.fcod.llwnd.net"
  4. Figure out the IPs for these 2 servers... simply ping it or something. Do it for both your local connection and your SSH servers, so you would end up with 4 different IPs. The hosts are on a round-robin DNS so they will give up different IPs.

Now to block the IPs, in Vista/Win7, you can simply use the built-in firewall that comes as part of the OS. Any low level firewall which can be custom configured should work. For Vista/Win7:

  1. Start menu -> type in "Windows Firewall with Advanced Security".
  2. Go to Outbound Rules in the left panel
  3. Click on New Rule on the right panel
  4. Select: Custom Rule, click Next
  5. Select: All Programs, click Next
  6. Select: Any for protocol type, click Next
  7. For scope, add the 4 IPs you found to the REMOTE IP addresses list, click Next
  8. Select Block the Connection, click Next
  9. Select all profiles, click Next
  10. Name it, and Finish

And finally...

  1. Set the socks proxy server in IE to localhost:8080 or whatever you specified (only the socks proxy, not the rest) and enable it
  2. Set the socks proxy server in whatever browser you're using (Firefox, Opera, etc). Chrome should use the IE setting.

And after that long process, you should be able to view any Hulu video.

The IPs/Servers might change, so you might need to expand your IP block list from time to time.

Mikito Takada: Thank you for the in-depth explanation! Awesome!

d: brilliant.

thank you!!!!!

done on my mac connecting to one of my servers in the states.

Didn't need to block any hulu IP's.

Mikito Takada: Good to hear that this still works!