I've researched and tried a lot of solutions online, but none seems to solve my problem, it seems something is missing.
I have domain registered at Godaddy, let's call it domain "X" I have 2 servers with 2 different hosting companies (Server A and B)
Domain X nameservers point to Cloudflare's DNS which I have set up with my Server A. No problem there.
I want a subdomain (sub.X.com) to point to Server B which already has a website in it with a different domain (Domain "Y").
So I did what most people say: Set up the A Record on Server A to point to Server's B IP address. However, all explanations end there, something seems missing, how can that subdomain know where are its files? I need to create an account for it on CPanel:
Now I go to CPanel on Server B and add an "Add-on Domain", which gives me an error (The domain's DNS I am trying to add do not match the current server's DNS). So ok, I add Server B's DNS to domain X in Godaddy
Now I have 4 different DNS registered at godaddy for the same domain (I added last 2):
- cloudflare.dns1.com
- cloufldare.dns2.com
- serverB.dns1.com
- serverB.dns2.com
I go to Server B's CPanel, and try to add a new "Add-on Domain", no error, now it lets me create it. I create the folder to host my subdomain files. So far everything works good. I go to "sub.X.com" on my web browser, it shows my website as expected. BUT now the problem is, when I visit "domain X" it shows an empty page (pointing to Server B, which is what I do not want; I want it to keep pointing to Server A), weird thing is, sometimes "domain X" loads as expected (pointed to Server A) and sometimes to Server B (blank page).
This is the point where It gets confusing, since I do not have much experience with DNS, and propagation time is a headache since I can't really see if what I'm doing works in real time.
Server B created some DNS zone "A records" after I created my "add-on domain", which have "domain X" pointed to server B's IP (Which should not be correct, since Server A also has an "A record" pointing to its own IP), so I figured deleting those records could solve the situation, but here's what I don't know what's happening, because sometimes "domain X" loads perfectly pointed to Server A, and sometimes, pointed to Server B.
What's the correct way to diagnose this? is this the correct way to tackle this situation? Should I keep on server B's CPanel ONLY the subdomain (sub.X.com) DNS records (and delete domain X records (CName, A, mail, ftp, etc)) ? Or is this problems just a matter of waiting for DNS and DNS config to propagate?