Use Dropbox to host public files on your own domain name

I’ve been using a Dropbox public folder and some Apache trickery to share files directly from Dropbox on my own domain at pub.noxon.cc. Dropbox is drag-and-drop file sharing at its finest, and by sharing my files on pub.noxon.cc instead of on dl.dropboxusercontent.com, my files are accessible to corporate folks who would otherwise find themselves blocked by an over-zealous web filter. Last but not least, if one of my files becomes too popular, Dropbox won’t shut down my account.

product logos

Dropbox doesn’t offer a custom hosting service, so I had to build it. I already have an Apache server, so I created a new virtual host and added some reverse proxy magic. I set up my virtual host as the origin server for the Amazon CloudFront content distribution network, ensuring a minimal load on my own server and the ability to handle virtually unlimited amounts of traffic.

Here’s a recipe for Apache 2.2, mod_proxy, and mod_rewrite:

DirectoryIndex disabled

ProxyRequests off

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
RewriteRule ^/(.*) http://dl.dropboxusercontent.com/u/xxxxxx/$1 [P,L]
ProxyPassReverse / http://dl.dropboxusercontent.com/u/xxxxxx/

Header unset cache-control
Header unset Pragma
Header merge cache-control max-age=3600
Header merge cache-control must-revalidate
RequestHeader set User-Agent Mozilla

The cache-control settings dictate that CloudFront should cache my content for an hour (3600 seconds). CloudFront currently ignores the specified max-age for 404 results, instead preferring to cache them for about 10 minutes. I’d prefer a shorter lifetime for failed requests, but that’s not easy with Apache 2.2; With 2.4, it’s do-able.

The requesting User-Agent override is necessary because Dropbox blocks requests from the Amazon CloudFront User-Agent.

Using mod_rewrite makes it possible to host overlapping content outside of Dropbox. If it exists on the server, it gets served locally; If it’s missing, Apache tries to fetch it from Dropbox. I locally host the favicon, robots.txt, a 404 handler, and a couple of other things.

If you want to use your own 404 handler, you’ll need this:

ProxyErrorOverride On
ErrorDocument 404 /path/to/404.html

Before you deploy something like this, carefully consider the security implications and make the necessary adjustments. Do you want PHP code in a Dropbox folder running on your server?

Dropbox public folders are not available to users who signed up for Dropbox after July 31, 2012.

Google Hangouts for iOS: Google Talk gets pushy

Since switching from Android to iOS, I’ve been looking for an instant messaging client that works well with Google Talk. Push notifications are essential for the “instant” part of instant messaging.

Unfortunately, most iOS Talk apps only have push capability until the application times out in the background (10 minutes); One client, Verbs IM Pro (App Store link), has server-based push notifications, but it times out after a week, and has some bugs and reliability issues. The developer hasn’t updated it for six months.

Google now offers a Hangouts app for iOS (App Store link), and it works very well. Most importantly, it has server-based push notifications that don’t time out. I’ve tested it by killing the app in the system tray. It’s really nice to have a way to keep in touch with friends without using SMS or iMessage, and it works well in conjunction with the built-in chat in Gmail and Google+.

If you want to use the new Hangouts app with a Google Apps account, your administrator will have to enable it for your domain first. Here’s the Google support article. Eventually, Google Talk will go away, so this is an early opt-in.

It’s unfortunate that Google ditched the standards-based XMPP protocol used by Talk. I’m not sure what this means for the future of third-party IM clients. If iMessage is anything to go by, there may never be any.