Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:

subdomain.MYAPP_DOMAIN.com

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:

  1. Add ServerAlias CUSTOMER_DOMAIN.com 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

1 Answer 1

ServerAlias *

As last entry, would you give a try?

share|improve this answer

Your Answer

 
discard

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.