Wednesday, September 13, 2017

Point client domain to my domain

Leave a Comment

I have a website with subdomains for my clients (wildcard subdomain)

client1.test.com client2.test.com 

I want my clients to use their own domain If they want.

what kind of record needs to be added to point

client1.com => client1.test.com shop.client1.com => client1.test.com 

I´m using the free plan of cloudflare for www.test.com but I´m open to change it if it can´t be done

4 Answers

Answers 1

CNAME records would work for that. You could also use A records to point to the same IP as test.com

Answers 2

You need modify the cname to redirect your client1 IP on their domain provider to client1.test.com

You need modify the cname to redirect your client2 IP on their domain provider to client2.test.com

CNAME setup on cloud flare is for paid plans only

https://support.cloudflare.com/hc/en-us/articles/200168706-How-do-I-do-CNAME-setup-

You might also want to check https://support.cloudflare.com/hc/en-us/articles/200168826-Does-Cloudflare-support-wildcard-DNS-entries-

Answers 3

You simply need to understand DNS records and how they work. You can find a good resource for this here, the most important of which is 'A record' in your case.

In summary however, before your clients can point their own domain to your system, they will have to configure their domain host records to point to your server/IP address.

For you, you don't have to do anything in Cloudflare but on your server. Say you have configured your webserver to recognize client1.test.com but client1 decides to use a domain client1.com and shop.client1.com, you have to set your webserver block for client1.test.com to also recognize these two domains aliases in addition to the original subdomain.

With Nginx, this will look like:

Server {   ...   ServerName client1.test.com shop.client1.com client1.com   ... 

You could take a look at this script if you are looking for how to automate this process.

Answers 4

Maybe you could use CNAME Record like this:

client1.com CNAME client1.test.com. shop.client1.com CNAME client1.test.com. 

The dot at the end is to tell the DNS not to complete your entry with the default-Domainname.

If you not must use an DNS to redirect, you also be free to use You even could do it by IPTables Forwarding. Good at this solution... you can decide which port will point to which ip... this way you could forward webserver to the Server of your Customer, but leave Mail at your server (for example)

Here how forward a port to another host that has an external IP:

sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport $port -j LOG --log-prefix="PreRouting $port..:" sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport $port -j DNAT --to $ip:$port sudo iptables -t nat -A POSTROUTING -j MASQUERADE  sudo iptables -A FORWARD -p tcp -i eth0 -o eth0 -s $ip --sport $port -j LOG --log-prefix="S Forward $port.." sudo iptables -A FORWARD -p tcp -i eth0 -o eth0 -s $ip --sport $port -j ACCEPT sudo iptables -A FORWARD -p tcp -i eth0 -o eth0 -d $ip --dport $port -j LOG --log-prefix="D Forward $port.." sudo iptables -A FORWARD -p tcp -i eth0 -o eth0 -d $ip --dport $port -j ACCEPT 

You also have to add this command to set on your network stack:

sudo sysctl -w net.ipv4.ip_forward=1 

This will work in a default DENY IPTables setup.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment