Domain mapping with cloudflare

Hi, what´s the best solution of setting up and managing multisite users domain, so that they also can be connected to cloudflare?

The main domain are using cloudflare name servers and are pointing to the server ip adress. Should I host the other domains on my server and use cloudflare nameservers, and point them back to the server and the wpmudev domain mapping plugin will take care of the rest?

This is really making my head spin. I would be grateful if someone finds a simple solution for this. The easier it is for the client the better :smiley:

  • Kasia Swiderska

    Hello Christoffer,

    Let me give you summarized idea about how Domain Mapping works. First you need to have a dedicated IP for your server and it should point to your main site if anyone enters the IP in browser. For example, your dedicated IP is "1.1.1.1" and your main site is "master.com". So your server has to be set up in such a way that when anyone enter "1.1.1.1" in the browser, it will open "master.com".

    Now suppose, you have a subdomain "second.master.com" and you purchased a domain (lets say second.com). So you should create an A record in "second.com" DNS Settings pointing to your dedicated IP, so when someone goes to "second.com", they are pointed to "1.1.1.1" and it will eventually open "master.com".

    Now if you map your domain, it will work. Because when you will go to "second.com", it will take you to "master.com", and as the domain is mapped, "master.com" already knows which subsite to server as the request came from "second.com".

    Procedure is almost same if you are using Cloudflare. In that case, you add Cloudflare nameservers in your Domain Control Panel DNS, and then set the A record in "Cloudflare DNS Settings".

    Please let us know if you still have any confusion. We will be glad to help.

    kind regards,
    Kasia

  • Christoffer

    Thank you Kasia, GREAT! That clears my head. Making this a practical example, I can just tell my clients to point their domain to the cloudflare nameservers, no matter if we or them host the domain. I will then point the domain to the master.com ip and it should work?

    And I would probably need to host the domain so that we can setup their email accounts, if they have no idea how to do that.

  • Nithin

    Hi Christoffer,

    Hope you are doing good today. :slight_smile:

    Making this a practical example, I can just tell my clients to point their domain to the cloudflare nameservers, no matter if we or them host the domain. I will then point the domain to the master.com ip and it should work?

    Yes, that sounds good. Create a A record/CNAME in cloudflare, and point it to your host. And let your users point main DNS to cloudflare nameservers.

    I hope this helps. Please let us know if you still need any further assistance. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

  • Christoffer

    I can´t get this to work, this is my setup:

    master.com (dedicated ip), nameservers points to cloudflare, cloudflare points to back to the server.

    first.master.com has a mapped domain "first.com" on a different registrar-host, the domain is mapped via the domain mapping plugin. first.com nameservers points to cloudflare, and cloudflare points back to master.com dedicated ip with a A and a www record.

    Browsing to first.com results to this page: "Default website page"

  • Christoffer

    Hello. Yes I´ve added the correct nameservers. Try to search with whois. Do I need to add the domain as an alias or parked domain, before it can have the mx and a records? Adding the domain as an alias:

    There was an error when the system attempted to create the alias. Park::park(xxx.net) failed: (XID c84x7m) Sorry, the domain is already pointed to an IP address that does not appear to use DNS servers associated with this server. Please transfer the domain to this servers nameservers or have your administrator add one of its nameservers to /etc/ips.remotedns and make the proper A entries on that remote nameserver.
  • Rupok

    Hi Christoffer,

    Sorry for the inconvenience you are having. Let me tell you the optimum process for using Cloudflare with Domain Mapping. From what I see above, I believe your setup is almost correct, maybe just a simple step is left. Let me describe the process firs.

    1. Suppose your main site is "master.com", it's hosted on "1.1.1.1" dedicated IP, it has a subsite "first.master.com", and you are trying to map "first.com" to "first.master.com". I believe, we are on the same page up to this.
    2. Now at first, you need to point "first.com" to Cloudflare, using Cloudflare nameservers. So when you go to "first.com", your request will be forwarded to Cloudflare.
    3. In your cloudflare, you should first add "first.com" and then set A record pointing to "1.1.1.1" so when requests comes to Cloudflare, it forwards your request to your server.
    4. Now, when Cloudflare forwards requests from "first.com" to your server, your server gets those request but your server doesn't know what to serve against this request. Normally when you have dedicated IP, hitting your IP opens up the main site, but on your server, you are using cPanel and when hitting your IP (31.***.***.2), it doesn't open your main site, rather cPanel default page opens. That means, now you need to add "first.com" to your cPanel as "Addon" domain and set the root folder of your main site as the location of this addon domain. When you do this successfully, your server cPanel will know what to serve (it will serve the main site, because you set the root directory of your main site for your addon domain - first.com) when requests come from Cloudflare regarding "first.com".
    5. When you main site gets the request from "first.com", it will serve "first.master.com" because it knows which subsite is mapped to which site.

    N.B. Cloudflare says:

    Define the wildcard subdomains in your DNS zone file during the signup process. CloudFlare cannot proxy wildcard DNS entries, so to benefit from CloudFlare performance and security, you must explicitly define any entries in your zone file as either CNAMEs or A record entries.

    Note: Having a proxy run over wildcard entries is available only at the Enterprise tier of service. The information above is related to customers on other CloudFlare plans.

    It means, when you have a subdomain multisite, you have to add each subdomain in Cloudflare DNS settings as CNAME because Cloudflare doesn't proxy wildcard subdomain. This is also a very important fact here.

    This is the total workflow. Now if you think, this will be very complex for you, I can try to fix the whole thing for you, but for doing that, I'll need your cPanel access, your Cloudflare access, and your Domain Control Panel (I found your mapped domain was bought from https://www.united-domains.de/) access. Can you send me message with above access credentials through our secure contact form here: https://premium.wpmudev.org/contact/ so I can try to fix this for you?

    Subject: "Attn: Rupok"
    - cPanel Username
    - cPanel Password
    - cPanel Login URL
    - Cloudflare Username
    - Cloudflare Password
    - Cloudflare Login URL
    - United Domains Username
    - United Domains Password
    - United Domains Login URL
    - Link back to this thread for reference
    - Any other relevant URLs

    Select "I have a different question" for your topic. This and the subject line ensure that it gets assigned to me.

    Please confirm here when you are done sending. I'll report you all the changes I have to make to fix this so you can know how this was fixed.

    I'm looking forward to hear from you and resolve this issue as soon as possible.

    Have a nice day. Cheers!
    Rupok

  • Bryant

    Christoffer I hope this information helps. We are trying to do the same thing and what we have come up with is using whmcs and cloudflare to provision our sites (we have tried many different solutions). Cloudflare has a plugin for whmcs that will do pretty much what you are trying to do, which I am assuming is 1) assign your users a cloudflare account, 2) route their domain to cloudflare dns, 3) use cloudflare flexable ssl.

    You will have to sign-up for a cloudflare partner account, but that takes 2 min. Then you just have to wait for them to respond. In total it took us about half a day to get whmcs set and provisioning sites with domain mapping.

    https://blog.cloudflare.com/cloudflare-whmcs-faster-websites-for-your-customers/

    We have tried other options, but this seems to be the best option so far.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.