Shortly after the big server rebuild a few weeks back I was examining the web server logs and I noticed that several sites were stealing okcomputer.org bandwidth by linking images from the okcomputer.org Photo Gallery directly into their web sites. This is just a tacky thing to do on numerous levels. In the past, I’ve had people contact me and ask for permission to use an image from the Photo Gallery, and I’ve always been happy to direct them to the photo’s owner. If they are given permission, I expect them to download a copy of image file and serve it directly from their own server. Otherwise, every hit to www.jack.ass causes a hit on my web server and uses some of my bandwidth.

So while I was rebuilding the web server I implemented a very common Apache mod_rewrite recipe so that these bandwidth thieves would get a very different image than the one they linked to. I didn’t do anything gross — just a small version of the pic of me playing the ukulele that I drag out every now and then. I week later I checked in on one of the bandwidth thieves’ web sites — a tourism site for some city in the Netherlands — and there I was wailing away on the uke. Not only was my recipe working, but this doofus hadn’t even noticed it yet.

As usual, I (a.) didn’t think this one through very well, and (b.) forgot I had even done it. That is until my dad tried to print some Photo Gallery photos through Shutterfly the other night. Luckily I was watching over his shoulder. Still, I was stumped for at least 8 seconds when the picture of Simon that my dad had selected showed up as me and my uke on Shutterfly.

Fixed now. As much fun as implementing this type of recipe always sounds when you read about it, it’s almost always more trouble than it’s worth. Almost.

Remember a few weeks ago when I was having all the wireless troubles?  The problem seemed to go away for a bit, and then WHAMMO!  It bit me again recently…again when I was downstairs in the living room.

Jessica heard me crying about it and mentioned that she had been having the same problem for the last few weeks.  What?!  Why hadn’t she mentioned this?  Dunno, but at least now I could eliminate my own laptop as the problem and concentrate on debugging a general wifi problem in the house.

The problem really only happened at DHCP lease acquisition time.  Once either of us had a lease we could roam all over the house, but successfully acquiring a lease in the first place was really only working upstairs.  Hmmm….

Well, apologies to all you potential Encyclopedia Browns out there, but you havn’t been given all the facts — because I had forgotten about one very important one: I had installed a Linksys WRE54G Wireless Range Extender for Jessica when she moved her office to the basement about two years ago.  Honestly, I had forgotten all about it.  I mean, I saw it every now and then, but I never bothered to think about what it was doing.  Or what it wasn’t doing.

One unplugged WRE54G later and Jessica and I are both acquiring DHCP leases all over the house again.  Apparently we were trying to associate with the range extender when our wireless interfaces were reconfiguring, and it must not have been bridging correctly with the router since I installed the new firmware.

I don’t know if we even need the range extender anymore since now that I’m running DD-WRT on my WRT54G I’m transmitting at 84 mW (instead of the default 28).  I’ll play around with connectivity in the basement this weekend, and if I still need the range extender I’ll configure WDS Bridging between it and the router so that they play together nicely this time.

I’ve spent the last few days investigating Plone as a potential replacement for WordPress for the okcomputer.org web site, but, as is frequently the case when experimenting with new technology around here, I’ve been beating my head against the wall trying to get my Plone installation to work behind an Apache proxy. I could successfully pull up the main page’s content in my browser, but none of the Cascading Style Sheets or Javascript files were making it. The result was less than inspiring. So while I was waiting for the tornadoes to pass through tonight, I fired up my browser, tailed my log files and started beating on it.

First off, the mod_rewrite rule from the RewriteRuleWitch wasn’t matching. Fantastic. Here’s what it gave me:

RewriteRule ^($|/.*) \
http://127.0.0.1:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/okcomputer/VirtualHostRoot$1 [L,P]

The root document was matching, but nothing else was. After setting my RewriteLogLevel to 9, I saw that the URI as it was being tested against the regex didn’t begin with a /. So I removed the slash from the regex and added one to the substitution pattern:

RewriteRule ^($|.*) \
http://127.0.0.1:8080/VirtualHostBase/\
http/%{SERVER_NAME}:80/okcomputer/VirtualHostRoot/$1 [L,P]

Now the RewriteRule was matching, but the proxied requests were generating 400 errors on the Zope HTTP server. The obvious culprits were the spaces in some of the URL’s, specifically in URL’s containing the string “Plone Default”. My browser was (correctly) escaping the spaces as “%20”, but by the time mod_rewrite had processed the request and passed it on to mod_proxy the spaces were back resulting in a malformed HTTP request.

I found the fix for this last bit at Velo World. The trick is to define a RewriteMap and then use mod_rewrite’s built in escape function, like so:

RewriteMap escape int:escape
...
RewriteEngine On
RewriteRule ^($|.*) \
http://127.0.0.1:8081/VirtualHostBase/\
http/%{SERVER_NAME}:80/okcomputer/VirtualHostRoot/${escape:$1} [L,P]

And success! But what a pain in the ass! I’d love to blame mod_rewrite, but I’m sure there’s some valid reason it doesn’t re-escape substitutions by default. Instead I’ll blame Plone. Why? Why do you put spaces in your %$#@! URL’s. And given the number of pages on the web explaining how to set up Plone behind an Apache server with mod_rewrite and mod_proxy — including Plone’s own documentation — how come none of them mentioned this? Very frustrated, but the problem is fixed, the tornadoes have passed, it’s going on 2:00 AM, I’m going to bed.

UPDATE 2/14/2008: Special thanks to Sascha, who’s been helping me debug my RewriteRule issue.  The Witch’s rule should work, I just can’t figure out why apache is stripping that slash of the front of my URI’s.  I’m not using a RewriteBase, and the RewriteRule isn’t an a .htaccess file, so I just have no idea what the problem is.