Manage Two cPanel Accounts for one domain name

myilraj

Member
Jan 14, 2018
13
0
1
India
cPanel Access Level
Root Administrator
Hi,
I request your expert advice in this regard. I am having a domain name, say "www. mydomain. com" hosted on a server 123.456.789.12 and the cpanel on this server can be accessed via "www. mydomain. com/cpanel".

Similarly, I have created another cpanel account with the same domain name but hosted on a different server 987.654.321.98. In the second, how can I access my cpanel account?

Kindly help me.
 

myilraj

Member
Jan 14, 2018
13
0
1
India
cPanel Access Level
Root Administrator
Yes,
Instance One: When I type my domain name www. mydomain. com/cpanel it will go to cpanel installed at 123.456.789.12
Same way,
How can I configure the URL to open the cpanel associated with the same domain (exact match) but installed at a different location 987.654.321.98?
 

wintech2003

Well-Known Member
PartnerNOC
Sep 15, 2010
98
26
68
Greece
cPanel Access Level
DataCenter Provider
Put the following in your domain's public_html/.htaccess
Code:
RedirectMatch 301 ^/cpanel2 https://your.second.server.com:2083/
So now you can visit the second server's cPanel, by entering www. mydomain. com/cpanel2 in your browser.
 

myilraj

Member
Jan 14, 2018
13
0
1
India
cPanel Access Level
Root Administrator
I encounter confusion here
1. Add the code in the htaccess file, but, in which server. The first server (or) second one.
2. In the code it was :// your. second. server. com:2083/ - but how www. mydomain. com/cpanel2 will redirect?

Please give me a clean code and procedures...

Note: The site is added to Cloudflare and so, the URL structure will be cpanel. domainname .com (main server)...
I want to access the child server via cpanel2. domainname .com
 

wintech2003

Well-Known Member
PartnerNOC
Sep 15, 2010
98
26
68
Greece
cPanel Access Level
DataCenter Provider
I'm confused too :) You said you wanted to use the exact same url (www.mydomain.com) which is why I suggested you can use an alternative "subfolder" URL to redirect to the second server.

If you're happy with using a subdomain, then I don't see any problem. You can call your first server cpanel1.domainname.com and your second server cpanel2.domainname.com - those will be two separate A records in your DNS section at Cloudflare.
You can reach each one's cPanel via their hostnames:

To answer your questions:
I encounter confusion here
1. Add the code in the htaccess file, but, in which server. The first server (or) second one.
2. In the code it was :// your. second. server. com:2083/ - but how www. mydomain. com/cpanel2 will redirect?

Please give me a clean code and procedures...
1. There is no first or second server, there's only one "live" server - the one that www.mydomain.com DNS records point to (in your example: server 123.456.789.12)
2. The .htaccess code I provided, will redirect requests from www.mydomain.com/cpanel2 => https://your.second.server.com:2083/

I assume you have created a DNS record for your second server (in your example: server 987.654.321.98) as an A record your.second.server.com
 

myilraj

Member
Jan 14, 2018
13
0
1
India
cPanel Access Level
Root Administrator
Really thank you so much for taking the time. I am still struggling to understand how to set this thing. Before that, Let me explain to you the reason behind this.

I have two servers, in which the first server IP 123.456.789.12 has all website files in its public_html folder. And, I have a separate application for Affiliate Program that allows users to register themselves and therefore I provide them login access. Currently, I have this setup under a sub-folder of the first server.

I am facing few issues which I cant explain here and for this, I want to move this sub-folder (sub-domain) to an entirely separate physical server with IP 987.654.321.98. But, I want to create the cPanel account using the first-level domain name and not a sub-domain.

I hope you can understand my requirement now. In this case, how can I access the cpanel of the second server with IP 987.654.321.98?

The first server has the URL https:// cpanel. mydomain. com (DNS settings handled by cloudflare)
I created an "A" Record as cpanel2. mydomain. com pointing to 987.654.321.98. After some time, I tried to access it via browser (https:// cpanel2. mydomain. com), but couldn't able to access it. I was redirected to cpanel2. mydomain. com/cgi-sys/defaultwebpage.cgi

Please help me to fix this and set proper redirection?
 

wintech2003

Well-Known Member
PartnerNOC
Sep 15, 2010
98
26
68
Greece
cPanel Access Level
DataCenter Provider
You will need to specify the cPanel port which is 2083 (for SSL connections).
So instead of https://cpanel2.mydomain.com please use https://cpanel2.mydomain.com:2083 (you might get an SSL warning, since this is probably not the real hostname of the server - you can ignore it).

If you haven't created the cPanel account in your second server's WHM, then instead of :2083, use :2087 which is the WHM port. From there you can create the cPanel account you want. You can of course create the account using the same domain, but you will need to create a subdomain to host that separate affiliate program.
It's not possible to host the affiliate program on a different server, and access it via subfolder. It needs to be done via subdomain (ie affiliates.mydomain.com) which will be pointing to the second server's IP.
 

myilraj

Member
Jan 14, 2018
13
0
1
India
cPanel Access Level
Root Administrator
Hi Wintech!
Thank you so much, I just typed as per your suggestion, and it is redirected to the hostname of the server.
cpanel2. mydomain .com:2083

Result URL: https:// server. hostname. com:2083

Here, I do not want to reveal the server hostname to the public. Kindly help me to hide it?
 

keat63

Well-Known Member
Nov 20, 2014
1,894
248
93
cPanel Access Level
Root Administrator
I'm coming to this thread rather late, and I'm by no means an expert.
Are you the only person who need access to the second Cpanel.

For me, the simplest solution would be to create an old fashioned batch file on your local PC which overwrites your local hosts file with one which contains the IP of Cpanel2.
It's cumbersome and crude, but simple and effective.
 
  • Like
Reactions: cPRex

wintech2003

Well-Known Member
PartnerNOC
Sep 15, 2010
98
26
68
Greece
cPanel Access Level
DataCenter Provider
I'm not sure I understand what the end goal is. Can you please explain in more detail what you're trying to achieve, so we can help you out?

I see you're mentioning two requirements now:

1. "I do not want to reveal the server hostname to the public"
There are several ways for someone to find your server's IP - no matter how hard you try to hide it. It depends on what you're using the server for.
If it's a webserver, you could hide it behind a proxy ie Cloudflare
If it's a mailserver, you can hide it behind a relay ie an antispam filter like SpamExperts.
Even so, if you send emails from that server, the server's IP will be in the mail headers.

2. "This is mainly to maintain all emails in a separate sever to avoid single-point-of-failure."
If what you're trying to do is "hide" your mailserver from the public, I would recommend you to just use a 3rd party solution like Google Workplace, Microsoft 365 etc.
 

myilraj

Member
Jan 14, 2018
13
0
1
India
cPanel Access Level
Root Administrator
Thank you So much Wintech2003. Really you have spent a long time for me, I am so grateful to you.
I am not concerned about revealing IP. But, I don't like to use "server hostname" to login via cPanel, instead, I want to access using the real domain name of the concerned cpanel account, that's all.

cpanel. domainname .com has the website files.
cpanel2. domainname .com has the website emails, and other applications installed in the sub-domain.

Both cpanel are on different servers though, I need to access through DIRECT URL.