One of our clients is a school district that wanted to make content on http://www.khanacademy.org/ (KA) available to users without Youtube. The KA site uses a bit of javascript to test if the user’s browser can get to youtube and if not it servers videos from an different source. Unfortunately this was not working for the client.
To solve the problem we setup mod_proxy as a reverse proxy. Then we used mod_headers, mod_filter and mod_substitute to rewrite the javascript going to client and force the use of the youtube alternative.
Here’s the apache config that does the content rewrite. It’s located in the reverse proxy virtual host:
1 2 3 4 5 6 7 8 9 10 11 |
<pre class="code"> # do not accept gzip - gzip bypasses filters RequestHeader unset Accept-Encoding # declare that content should be filtered through mod_substitute FilterDeclare NOTUBE FilterProvider NOTUBE SUBSTITUTE Content-Type $text/html FilterChain +NOTUBE # change the javacript test so that it always failes Substitute "s|youtube.com/favicon.ico|youtube.com/nfavicon.ico|in" |