So, the new hotness is running Rails apps (typo, in my case) on a mongrel server, with Apache acting as a reverse proxy in front (prefereably serving the static files from there, rather than mongrel). This is a good idea (well, better than FastCGI), and not particularly challenging to implement.
Unless you have a tilde in the path of the URI for your app. As I do for typo. The comes the dreaded
NOT FOUND. Again, and again, and…
After eventually breaking down and packet-sniffing localhost, I discovered the problem: mongrel was recieving an encoded version of the URI, with the tilde turned into %7E. And mongrel, in its infinite wisdom, treats URI encoded URLs as being fundamentally different to non-encoded ones, so
/%7Erodgerd are fundamentally different paths in mongrel-land. This is Not Good.
There are a number of problems here:
- Mongrel is broken. Treating a legally-encoded URI as being different from a legal but unencoded URI when it’s the same damn URI is idiotic.
- Apache isn’t adequately configurable. There’s no reason to force-encode the tilde, and mod_proxy doesn’t let you configure that.
- I’m not shifting my site URI because some software is broken.
After various attempts to solve the problem failed, Google led me to a helpful Apache bug report; in a broken world, yes, patching the Apache source to force non-encoding of the tilde is the least-bad solution for me. The best, of course, would be to go away and win an argument with the mongrel authors about why their web server is Wrong, but I suspect that’s remarkably unlikely.