How to host subdomain on a different server than the main domain?

skrl

Active Member
Mar 18, 2021
37
6
8
Kingston
cPanel Access Level
Website Owner
I have mydomain.com served from Host A (IIS). mydomain.com is developed with ASP.NET.

I need to serve a subdomain.mydomain.com from Host B (Apache). subdomain.mydomain.com will be developed with Drupal.

I thought all I would have to do would be to create an A record in my registrar's DNS nameservers to point to the public IP of the Host B, and that would be it, and I would be able to then proceed with my installation as soon as the DNS propagation would have finished. My Host B support team says that that would not work, although they haven't made it crystal clear why. They've said it's something to do with the virtual machine engine the WHM has been installed on to. Please kindly note that the Host B is a dedicated server, and I would expect there would be more flexibility in terms of available options.

I am mostly front-end oriented, and I need to better understand why that would be the case.

Would you happen to have available any resources I could spend time reading to better educate myself on this?

Any obvious insight at hand that I might be overlooking would be also really appreciated.
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,234
2,422
363
cPanel Access Level
Root Administrator
Hey there! As far as the internet portion of the traffic, you are correct - you just need the A record where your DNS is hosted to point to the correct system.

However, you also need to have the correct entries setup on that webserver as well. For example, on a cPanel machine, you'd need to ensure the subdomain is created in cPanel or else Apache won't know where to serve the content from. Even though the DNS may be pointed properly, the webserver side still needs to exist so it knows how to handle that.

Maybe that is what they were getting at?
 

skrl

Active Member
Mar 18, 2021
37
6
8
Kingston
cPanel Access Level
Website Owner
Hey, thank you for your prompt input. So when the account for the subdomain is created, would that be all on the server side under regular configuration?

By the way should there be any problem whatsoever creating the cPanel account, and associating it with the subdomain.mydomain.com as the primary domain? Does cPanel really care if that domain name already exists or not? Or does it care whether it is pointed to a different host or not? To my knowledge it does not, but I just want to double check because I am at a point where I am doubting everything I think I knew...

The server hosts another installation as well. There's only one public IP, and zero dedicated ones. But I would not expect that to be a problem; when you purchase a shared hosting plan that is usually the case also, isn't it?

How do you generally go about doing such implementations as the one I am trying to achieve here? (edit: What settings should I ask them if they have set them up correctly?)
 

ffeingol

Well-Known Member
PartnerNOC
Nov 9, 2001
856
367
363
cPanel Access Level
DataCenter Provider
It's easy and we do this all the time:

  • On Server-A create mydomin.tld ( your IIS server)
  • On Server-B create subdomain.mydomain.tld (the cPanel server)
Then in your DNS you just need to create the "A" record to point subdoamin.mydomain.tld to the IP assigned in cPanel.

cPanel is perfectly happy to create the account as a sub-domain.
 

skrl

Active Member
Mar 18, 2021
37
6
8
Kingston
cPanel Access Level
Website Owner
It's easy and we do this all the time:

  • On Server-A create mydomin.tld ( your IIS server)
  • On Server-B create subdomain.mydomain.tld (the cPanel server)
Then in your DNS you just need to create the "A" record to point subdoamin.mydomain.tld to the IP assigned in cPanel.

cPanel is perfectly happy to create the account as a sub-domain.
So I should not need a dedicated public IP just for every individual cPanel installation. I just need a cPanel account for every installation, with subdomain.mydomain.com as my primary domain associated with this one account in this case. Then the A record goes in my DNS, and the rest should be taken care of by the cPanel and/or Apache; have I got it down right? No special back-end handling on behalf of Host B?

That is how I had everything in my mind to start with, but then my back-end support said it can't be done, or it wil not work, or it is not as easy and what not, and got me into doubts.
 

PeteS

Well-Known Member
Jun 8, 2017
389
88
78
Oregon
cPanel Access Level
Root Administrator
Will this also work if the subdomain is a set up as an addon domain? Like this:

Server A hosts example.com
Server B hosts domain.com

Can I do this on server B? --> setup an addon domain in domain.com's account of subdomain.example.com Or will this yell at me because example.com is DNSed to another server?

For DNS, A & B are in the same DNS cluster. Not sure if that helps or complicates, but you would need to make sure example.com's DNS zone points subdomain.example.com to the shared IP of domain.com's server, and if a DNS zone was also created for subdomain.example.com I would assume that could be deleted.

Am I crazy? ;)
 

PeteS

Well-Known Member
Jun 8, 2017
389
88
78
Oregon
cPanel Access Level
Root Administrator
I'm not crazy... it works fine. :)

I had some time to test this and got it working pretty easily. I was testing on a non-clustered server, but I think it shouldn't matter. I did have to enable the proper nameserver IP for the test domain in Home / IP Functions / Configure Remote Service IPs.

The only correction I would make is to the DNS comment... YES to making the example.com DNS zone point subdomain.example.com to the domain.com IP, but NO to deleting the DNS zone on domain.com's server created for subdomain.example.com.
 
Last edited:
  • Like
Reactions: cPRex

PeteS

Well-Known Member
Jun 8, 2017
389
88
78
Oregon
cPanel Access Level
Root Administrator
Almost a year later and I ACTUALLY need to do this, and it isn't working.

I have example.com on server alpha.server.com.
I need to create sub.example.com as an addon domain on server beta.server.com.
The beta server hosts the domain server.com.
Both servers are in the same DNS cluster.
So the addon domain would be sub.example.com and the subdomain would be sub.example.com.server.com.
I must do it as an addon rather than a new account because the beta server only has a one account cPanel license.

I would think all I need to turn on is "Allow Remote Domains" in Tweak settings on the beta server (and I have).

The error I get is "The domain “sub.example.com” may not be created by “server” because “example.com” is already owned by another user." This all seems logical that it's seeing that, but shouldn't "Allow Remote Domains" let it go through? (Both example.com and server.com are owned by root on their respective host servers.)

I tried turning on "Allow users to park subdomains of the server’s hostname." and turning off "Check zone owner" in Tweak settings on the beta server but those made no difference. I also tried adding a Remote Name Server IP for the DNS cluster in Home / IP Functions / Configure Remote Service IPs on the beta server and that didn't help either.

Is this not possible? What am I missing?
 
Last edited:

ffeingol

Well-Known Member
PartnerNOC
Nov 9, 2001
856
367
363
cPanel Access Level
DataCenter Provider
That error means exactly what it says. That sub-domain already exists on this server or (if the server is part of a DNS cluster) within the cluster and is owned by a different cPanel user. You'll need to look in DNS zones and/or the Apache config to see what other account has that sub-domain setup.
 

xpy-xpy

Member
Jan 13, 2023
22
12
3
GE
cPanel Access Level
Root Administrator
That error means exactly what it says. That sub-domain already exists on this server or (if the server is part of a DNS cluster) within the cluster and is owned by a different cPanel user.
Not exactly. In this case the error says that it is example.com that exists on the server and is owned by another user, but not sub.example.com which PeteS is trying to setup.

In my case the solution to a similar issue was to check "Allow cPanel users to create subdomains across accounts" in WHM/ Tweak Settings before attempting to setup sub.example.com in Cpanel.
 
  • Like
Reactions: PeteS

PeteS

Well-Known Member
Jun 8, 2017
389
88
78
Oregon
cPanel Access Level
Root Administrator
Not exactly. In this case the error says that it is example.com that exists on the server and is owned by another user, but not sub.example.com which PeteS is trying to setup.

In my case the solution to a similar issue was to check "Allow cPanel users to create subdomains across accounts" in WHM/ Tweak Settings before attempting to setup sub.example.com in Cpanel.
Correct, the subdomain doesn't exist, it's an ownership restriction.

I had been looking for the "Allow cPanel users to create subdomains across accounts" setting and couldn't find it, and I *though* I had seen it mentioned in older posts, so I assumed it had been removed. NOW I see that it IS in 108, but not 106! The beta server is still on 106, so I think I have my solution! Thank you @xpy-xpy for causing me to look for it again.

I'll assume that's the fix, and will report back if it doesn't.
 

PeteS

Well-Known Member
Jun 8, 2017
389
88
78
Oregon
cPanel Access Level
Root Administrator
Ummm.... :rolleyes: Apparently the single account cPanel version omits "Allow cPanel users to create subdomains across accounts" and "Allow WHM users to create subdomains across accounts" from Tweak settings. So maybe those settings weren't just added in 108.

I presume the thinking is "Who needs that if there's only one account?" Me! *raises hand* That ignores my scenario where the other user account is on another server!

@cPRex can you give some insights? If it's as I presume, then that should be addressed asap. (In the mean time, is there a manual work-around?)
 

PeteS

Well-Known Member
Jun 8, 2017
389
88
78
Oregon
cPanel Access Level
Root Administrator
Can you check /var/cpanel/cpanel.config to see if "allowremotedomain" exists in that file on your server? If so, you can modify that to "1" over the command line to make that change without using the cPanel interface.
I see allowremotedomains=0 (plural) which I assume is it.

I'll change to 1 and test, but will that persist or be overwritten.

Once the addon has been created the setting is not relevant (to that addon), correct?
 

PeteS

Well-Known Member
Jun 8, 2017
389
88
78
Oregon
cPanel Access Level
Root Administrator
Can you check /var/cpanel/cpanel.config to see if "allowremotedomain" exists in that file on your server? If so, you can modify that to "1" over the command line to make that change without using the cPanel interface.
Not quite, but close enough to get me to the right place.

The setting needed is: allowparkonothers=1

I set everything else to defaults again and that one setting change let it create the subdomain and DNS record. (Note, this was for doing it from within a cPanel account, as opposed to the setting: allowwhmparkonothers which won't allow cPanel accounts to do this.)

Just a note for future readers, this isn't necessary to do manually unless it a single account license and thus "Allow cPanel users to create subdomains across accounts" and "Allow WHM users to create subdomains across accounts" is missing from Tweak settings.

Thanks for the help @cPRex, and can this be put back in the single account license package? I feel this is a bug report, and not a feature request... ;)
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
15,234
2,422
363
cPanel Access Level
Root Administrator
It's definitely an issue, but I'm trying to understand the background of what led to this setting being necessary on a Solo account. Can you get me a summary of what led to this need just so I can make sure I'm reporting things correctly to the devs?