Tumblon allows users to create blogs with a custom subdomain like mysite.tumblon.com. Today, I was working on configuring asset hosts for Tumblon to improve download performance, and I ran into a snag.
We have a list of restricted subdomains which are not available for users to register, including the default Rails asset host names: assets0.*, assets1.*, assets2.* and assets4.*. I set up a new virtual host for the asset host with server aliases for the names (we have wildcard DNS to support the app’s subdomains).
This worked in the main application, but broke with the subdomains. All the subdomains started resolving to the asset virtual host (I think because it was first).
So I went back to the drawing board. I deleted the assets virtual host and came up with this re-write rule to fix my problem:
# Check for asset hosts
RewriteRule %{REMOTE_HOST} ^assets\d.* [L]
What this does is matches any request like that starts with assets and a digit and stops it from going to Rails, thus having Apache handle it. This is above the rewrite rule for the Mongrel Cluster proxy, so any other subdomains will go to Rails.
I put this out there in case it helps anyone else who has this problem.

