Search code examples
ruby-on-railsruby-on-rails-3.2subdomainwildcard-subdomain

Rails app dynamic subdomain not working on apache and passenger


Same question asked multiple times but no feasible answer is available yet and also the available answers just support hard coded subdomains:

I applied dynamic subdomain in my rails 3.2.13 app and its working locally by using lvh.me instead of localhost as specified by rails cast.

My urls are like

local

subdomain.app_name.lvh.me:3000/

In porduction:

subdomain.app_name.abc.com/

My site is on appache + passenger

and it seems that appache not forwarding request to passenger.

Am I missing something?

I followed this http://railscasts.com/episodes/221-subdomains-in-rails-3

Note:

I don't need hardcoded subdomains as they will be generated dynamically and at extensive level.


Solution

  • 1) Point *.abc.com in your DNS setup to your server.

    2) Setup an Apache vhost to catch the star pointer:

    <VirtualHost *:80>
    
      ServerName  abc.com
      ServerAlias *.abc.com
    
      DocumentRoot /home/public_html/yourapplication/current/public
    
    
    </VirtualHost>