Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 CNAME

style domains and the other is using a Freemium style:

The subdomain works perfect with since I have ServerAlias * in my Apache VirtualHost configuration.

So to make my paid version work I have a couple options:

  1. Add ServerAlias entry into my Apache config.
  2. Change to IP-base VirtualHosting
  3. Proxy infront of Apache to swap HTTP_HOST with HTTP_X_FORWARDED_SERVER and 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?

share|improve this question
ServerAlias *

As last entry, would you give a try?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.