So I have a Rails application behind Apache. It is running via Thin, but all of this really doesn't matter. I'm having trouble getting my SaaS style CNAMEs working.
Currently I have two different types of accounts, one is paid type using
CUSTOMER_DOMAIN.com CNAME MYAPP_DOMAIN.com
style domains and the other is using a Freemium style:
The subdomain works perfect with since I have
ServerAlias *.MYAPP_DOMAIN.com in my Apache VirtualHost configuration.
So to make my paid version work I have a couple options:
ServerAlias CUSTOMER_DOMAIN.comentry into my Apache config.
- Change to IP-base VirtualHosting
- Proxy infront of Apache to swap
HTTP_X_FORWARDED_SERVERand pass that through the Apache proxy to the application.
Obviously solution 1 doesn't human-scale well. Solution 2 seems like it is probably the right thing to do, but haven't looked that much into it. If I went with Solution 3, I would probably ditch Apache and just go from Nginx directly to my application, which is out of the question with management currently.
So is there another solution, possibly via directly in Apache that would solve this? I was thinking about modifying the headers myself in a similar fashion to how Rails
before_filters works with controllers, but looking around I can't seem to find anything in Apache. Ideally I would like to swap the headers around before Apache gets to the VirtualHost, but I'm afraid I can't find anything. The kicker is that I can't mess up the other applications that are also hosted via the same Apache instance. Ideas? Suggestions?