It worked fine for many months, but stopped working a short while ago. Why? Because Google started forcing all Google Sites pages to load over SSL -- over https instead of http. Loading them over http without SSL would just redirect you to the https version of a page.
Overall, a good thing. HTTPS Everywhere. I approve.
But, browsers nowadays want to prevent you from getting tricked into loading a site other than the one you've gone to. So if you try to do a frame-based redirect where part of it is https and part of it is not, the https stuff won't load. It'll just sit there blank, empty.
Thus, it broke the bar's website. The frame redirect wouldn't load the Google Site, it just sat there with a big blank screen.
The fix? Implement a quick-and-dirty live proxy on my linux box that will pull through the Google Site pages and display them (without using SSL) directly, as though they're actually hosted on my server. It turned it out to be pretty easy.
I configured the Apache virtualhost to allow *.cgi as a valid file type, an executable file time. I also configured the virtualhost to use index.cgi as the 404 error handler. This means that one simple little CGI will handle both the calls to the top level page and any subpages.
Here's what that index.cgi looks like:
cat << EOF
Content-Type: text/html; charset=utf-8
if echo "$REQUEST_URI" | grep -qi "[a-z]"
$LYNX -source "https://sites.google.com/$REQUEST_URI"
$LYNX -source "https://sites.google.com/site/rogersparkoasis/"
And here's what the Apache configuration options look like for that virtualhost:
AddHandler cgi-script .cgi .x
ErrorDocument 404 /index.cgi
The proxy could be developed further to pull down and host images, or to rewrite URLs in the HTML output to link to the custom website URL instead of the Google Sites URL, but I think this is good enough for government work.
Post a Comment