Mobile app version of vmapp.org
Login or Join
Gloria169

: How to set up wildcard subdomain CNAME records for a multi-tenant app? We are trying to point a heroku staging app (something.herokuapp.com) to a subdomain on our domain (staging.company.com).

@Gloria169

Posted in: #Cname #Dns #Domains

We are trying to point a heroku staging app (something.herokuapp.com) to a subdomain on our domain (staging.company.com).

Everything else on the domain (*.company.com) goes to our previous production app.

I'm having trouble pointing subdomains of the subdomain to the heroku staging app. For example, login.staging.company.com should point to staging's login portal, and hospital.staging.company.com should load our app with the Hospital client's data.

I have 3 relevant CNAME records:


* points to company.com. (Everything goes to production)
*.staging points to something.herokuapp.com.
staging also points to something.herokuapp.com.


Current behavior is that login.staging.company.com goes to app.company.com, thus it goes to our production app instead of our heroku staging app. However, login.staging.company.com/users/sign_in goes to our staging app just fine, but it is the ONLY link that is going to our staging app.

Which records do I need to add/remove to make sure that everything under *.staging.company.com goes to our heroku staging app, and everything not under that continues to go to our production app?

Ex. hospital.staging.company.com should go to staging, while government.company.com should go to production.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gloria169

1 Comments

Sorted by latest first Latest Oldest Best

 

@Kevin317

Domain hosting has two parts:


the DNS must point the domain to a server
and the server must recognise the domain


You should verify both.


DNS points the domain to the right server:


check using dig (or drill), nslookup or even simply ping or traceroute. All will take a domain name and let you know what the final resolved IP is. Check that it matches what you expect it to be.
or you can use online tools like dns.squish.net which will give you a much more detailed view of how the whole process goes.

Server recognises the domain


This is specific to protocols which include the domain in the request (such as HTTP/HTTPS), and is of course vital for virtual hosting (hosting multiple domains on the same server with the same IP). This is something that is configured on the server.

The server must thus recognise all domains you are pointing to it (if you just point a domain to a server using DNS, and the server does not know about it, it'll have a hard time knowing what it should return). Depending on your hosting situation, this may be more or less complex to handle. Also, managing wildcard domains may add another hurdle, depending on whether you actually configure individual sub-domains on the host, or (try to) have it recognise a wildcard as well (not all servers/hosts can).

Once the request gets to the right virtual server, then you may have additional issues with local scripts, .htaccess files, Rewrite Rules, and more, which may not be properly configured and redirect somewhere else.


start by using a tool such as curl (with the -v option) to see what happens when you connect to the URL (is there a redirect — or several?)
check .htaccess files for Redirect* and RewriteRule directives which may cause the redirect
there may be further redirects generated in code, but then we would need a lot more details about what software you are running.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme