C4f1151075b447779af31e99d6cf70e2c6eb47ac
By:
newbie

setup CNAME redirect or custom domain with url masking

May 8, 2017 1.9k views
DNS Nginx Ubuntu 16.04

hi,
we have an ecommerce app where customers store is located in subdomain.mydomain.com

now how can i offer my customers to have their custom domain to be treated as allies with that sub-domain.

for example,
www.customdomain.com will resolve subdomain.mydomain.com with url masking.
meaning www.customdomain.com will serve exact content of subdomain.mydomain.com without changing url.

i tried with adding CNAME record www.customdomain.com pointing subdomain.mydomain.com but that didnt worked.

i should add, subdomain.mydomain.com is on https and most likely customers wont have any server to setup ssl for their domain.

i would really appreciate some help here.

regards,

2 Answers

@newbie

Pointing a root domain, such as domain.com at a sub-domain is referred to as CNAME Flattening. It can be also be achieved using an ALIAS or ANAME record, though many DNS providers do not yet provide support for such (DigitalOcean doesn't, yet).

The two work-around options would be to use CloufdFlare for every domain -- they allow you to point a domain to a sub-domain using a CNAME entry -- or use a plugin, if one is available for your app.

There are other DNS providers, such as DNSMadeEasy and DNSimple, though I believe they cost as much if not more than the premium plans offered by ClouldFlare.

Although it's an extra step and they would need to allow CloudFlare to host the DNS for their domain, it can be achieved through them, even on the free account.

  • @jtittle
    thanks bro.
    im already using cloudflare as DNS service. and i could ask my customers to add their domain to cloudflare as well. thats not a problem.
    but unfortunately it didnt worked for me. check my earlier email, i tried that cname on cloudflare.

    and im not only talking about root domain. customers root domain & subdomain both needs to be allies with my subdomain.

    for example
    custom-domain.com allies with sub.mydomain.com
    www.custom-domain.com allies with sub.mydomain.com

@newbie

With CloudFlare, as long as the www entry is setup as a CNAME pointing to the main domain that you are flattening, it should work as any CNAME would under normal circumstances.

That being said, it does appear things have changed with CloudFlare so normal CNAME setup for www may not work with the flattened CNAME. The Pro plan offers more features it seems and the ability to flatten all CNAME entries, which may be what you actually need -- but it comes at a cost of $20/month per domain.

The alternative would be to check with other DNS providers, such as DNSMadeEasy or DNSimple and see what their costs would be for similar solutions -- or use a plugin / build one that will work for your application.

If more providers supported flattening, ALIAS, or ANAME, this wouldn't really be an issue and you wouldn't need to rely on CloudFlare, other DNS providers, or code-based work arounds, but not all do just yet.

Have another answer? Share your knowledge.