C4f1151075b447779af31e99d6cf70e2c6eb47ac
By:
newbie

CNAME other domain with my subdomain with masking

June 13, 2017 562 views
DNS PHP Nginx Ubuntu 16.04

Hello,
im stuck with a particular issue here. i have posted it here before, but didnt had time to follow up. now im really stuck and need solution badly.

you see i have a ecommerce solution where each of my customer have their own site hosted on my subdomain. eg. site1.mysite.com, site2.mysite.com

now i want to have my customers own domain to CNAME with my sub-domain. eg. www.domain1.com will work as site1.mysite.com, www.domain2.com will work as site2.mysite.com

i tried with cludflare few things,
i added domain.com in cloudflare as CNAME
Name(domain.com) Value (site1.mysite.com)
it works actually, but when i type domain.com on browser, the url change to site1.mysite.com. is it possible to keep the url domain.com in browser something like url masking.

if its possible, please guide me a bit. if not possible in cloudflare, please suggest me how can i achieve that in alternative way.

thanks in advance.

1 Answer

Hi @newbie

Nginx right? And which ecommerce system are you using?
Can you post your Nginx server block of site1.mysite.com/domain.com? Change the domains if you want privacy.

  • @hansen
    thanks for replying.

    here is my nginx server block
    https://pastebin.com/jMTUCfuJ

    if you want detail insight, please give me your email and ill give you original domain name.

    • @newbie

      Okay, you're actually redirecting HTTP traffic to HTTPS, but by doing so, it's actually redirecting any domain in the server_name to the first domain of the list.

      So it's actually doing this:

          server_name ecommerce.mysite.com domain.com;
          return 301 https://ecommerce.mysite.com$request_uri;
      

      If you change around, it's putting primary focus on domain.com instead:

          server_name domain.com ecommerce.mysite.com;
          return 301 https://$server_name$request_uri;
      

      And I'm not sure how you handle the include snippets/ssl-wildcard.conf; for two different domains, but that is in general tricky within the same server block.

      But the main question is actually; do you want to be able to use ecommerce.mysite.com at all or is the only focus actually domain.com?
      If you only want domain.com, then simply remove ecommerce.mysite.com and you're done.

Have another answer? Share your knowledge.