mchchu88
By:
mchchu88

How to configure DNS for Rails 4 multi-tenant app on postgreSQL schemas

March 5, 2015 1k views
PostgreSQL Nginx Ruby Ruby on Rails DigitalOcean DNS Ubuntu

I recently deployed my code successfully to my droplet by following the available tutorials on the site. Visiting the root page seems to be working correctly, however, after I create a new account with a new subdomain, I am unable to visit the subdomain's login page at subdomain.domain.com/users/sign_in with rails complaining the route does not exist.

Surprisingly, I am able to get to the correct subdomain's login page by adding another level of subdomain in the address for example:

I cannot reach subdomain's login page from subdomain.domain.com/users/sign_in but can reach subdomain's login page with subdomain.XXX.domain.com/users/sign_in where XXX is any character. My app seems to recognize the subdomain name only after i put in the XXX value.

My DNS settings are:

A record, @ to 123.123.123.123
A record, * to 123.123.123.123

My zone file is as follows:

$ORIGIN myapp.com.
$TTL 1800
myapp.com. IN SOA ns1.digitalocean.com. hostmaster.myapp.com. 1425577279 10800 3600 604800 1800
myapp.com. 1800 IN NS ns1.digitalocean.com.
myapp.com. 1800 IN NS ns2.digitalocean.com.
myapp.com. 1800 IN NS ns3.digitalocean.com.
myapp.com. 1800 IN A 123.123.123.123
*.myapp.com. 1800 IN A 123.123.123.123

Be the first one to answer this question.