A Simple Apache2 Live Proxy

I help my friends at the corner bar set up a website using Google Sites. It works great. It's super easy to update and they have a lot of fun with it. I set up a frame-based redirect to map their domain name onto their Google Sites URL.

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:


#!/bin/bash
LYNX="/usr/bin/lynx"
cat << EOF
Content-Type: text/html; charset=utf-8

EOF
if echo "$REQUEST_URI" | grep -qi "[a-z]"
then
$LYNX -source "https://sites.google.com/$REQUEST_URI"
exit 0;
fi

$LYNX -source "https://sites.google.com/site/rogersparkoasis/" 

And here's what the Apache configuration options look like for that virtualhost:
<Directory "/var/www/oasis">
    Options +ExecCGI
    AddHandler cgi-script .cgi .x
</Directory>

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.

Lincoln SYNC with MyLincoln Touch

We recently bought a new car. Not just any new car, but a new new car, and a fancy one at that: a 2014 Lincoln MKZ. We love it. The car has the smoothest ride of any car we've driven or ridden in, and I can't believe how much pick up it has given that it's only a 2.0L V4 Turbo. Every time we go for a drive, we literally again think to ourselves, "we really love this car." And it has zero torque steer-- our last car had enough pull to annoy me regularly. Maybe that's just a side effect of moving from FWD to AWD, but regardless, I couldn't be happier.

It seems like there's never a great time to buy a car, if you want perfect iPhone integration. Apple's on the cutting edge, only recently announcing CarPlay, with automotive manufacturers rushing to implement it as quickly as possible. Meanwhile, our Lincoln has SYNC with MyLincoln Touch (aka MyFord Touch), a system that allows voice control over seemingly all of the music, GPS and environmental controls. It's worth nothing that Microsoft and Ford had a falling out over the system, and it's likely to be replaced by something else in a couple of years. (Blackberry? QNX? Are you kidding me?)

Reviews from 2012 and prior almost universally pan the SYNC system, something that unfairly haunts Google searches about the technology. Read a little deeper and you'll see that a major update in 2012 addressed just about all prior issues. People who have only had experience with prior, less well-liked revs of the software love to tell you how much they hate it. Or they'll love to tell you how much their cousin hated SYNC in their 2009 Ford Focus and what suckers we are for buying this and we're going to hate it. Because obviously how this works today and how it worked in a 2009 Focus is exactly the same. Thanks, jerk.

Forget about all of that noise. Truth be told, the SYNC with MyLincoln Touch system works quite well and we're happy with it. There's only a couple of things worth noting that I would consider to be limitations.

One, SYNC will read out loud text messages from your phone if you have an Android smartphone, but not if you have an iPhone. I'm not sure what Apple is doing differently here, but I wish they'd address it. I can't imagine it'd be hard to fix in an iOS software update, and I know a lot of people have vehicles with the SYNC functionality. (Oh wait, did this get fixed? Maybe. I will need to investigate.)

Two, programming the navigation system to give you directions is like taking a step back in time a couple of years, if you're used to Google Maps or Apple Maps, with their slick ability to say things as simple as "take me to the nearest Dairy Queen." The SYNC system's ability to understand voice commands is pretty limited, and you basically end up having to spell out house numbers and it usually ends up taking a couple of tries to get it to recognize the street name and city I'm looking for. That's not a deal killer, but it's not super slick, either.

Thankfully, there are more than a couple of ways you can work around it:

  • Use your iPhone for turn-by-turn directions instead. Sync the phone up via Bluetooth before you do tell it your destination. Then, after you tell it your destination, the phone will interrupt the music as needed (over Bluetooth) to give you verbal turn-by-turn directions. The car is a little confused; it thinks it's a phone call and will show "Call ended" on the screen after each interruption. This is harmless, however.
  • Use SYNC Services to help you set the destination for the car's navigation system. Push the voice button and say "Services." It'll use your Bluetooth-connected phone to connect you to the SYNC Services phone robot. After connected, say "Directions," and the phone robot will walk you through a much simpler and robust location-finding process. After it has found your location for you, it will ask you if you'd like to download the location to the car's GPS. You'll say yes, and it will silence the speaker for a moment, while performing a modem-like download over the phone, sending location information directly into your car's navigation system. This works pretty slick, and it's what I use most of the time. If you've ever had a GM automobile with OnStar, you'll see a lot of similarities here -- you can even connect to a real live human to have them look up a destination for you. (SYNC Services is a hidden gem; it is essentially OnStar for free, using your own cell phone instead of using a dedicated cell phone built into the car. I hope I never have to use the SYNC 911 Assist feature, but I'm glad it's there.)
  • Use the "Send to Car" iOS application on your iPhone. Trust me, spend the $3.99 on this app. If you have Ford or Lincoln SYNC, this app performs bridges Apple Maps and your car's navigation system capably. It works like this -- set up your Ford/Lincoln owner account login information in the app once. Then you go to Apple maps, find a destination, and choose "Transit" as the directions mode, inside of Apple Maps. Apple Maps will then ask you to pick which app you want to use for routing to this destination. Choose Send to Car. The Send to Car app will open, and then you push SEND to have it relay your destination into your Ford/Lincoln owner account. How do you get this destination into your car? Easy. Just push the voice button on the steering wheel, and say "Services." As soon as you connect to the Services phone robot will say (paraphrasing), "I see that there is are MapQuest directions waiting for you, would you like to download them now?" You reply with yes, and it will download the directions to your car, and you're all set.

That third option in particular is mighty cool, and I'm sure it's something I'll be using a lot in the near future. And it was hard to find information about it online, so I decided to write it all up here, with hopes that the next person looking for help stumbles across this info here and is able to put it to good use.