Rename /cpanel or /WHM become /newname

b0y

Registered
Aug 11, 2011
1
0
51
hello. i'm new user on here.
i'm just want ask. can we rename cpanel login url for security reason
from default url
http://mydomain.com:2086/ or http://mydomain.com:2082/ or http://mydomain.com/cpanel/ or http://mydomain.com/whm/

become

http://mydomain.com/newname/ or http://mydomain.com:newport/
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
You can change the cPanel port in /var/cpanel/cpanel.config file. Search for this line:

Code:
port=2082
If you change it to 3050, for example, then 3050 will work for http and 3051 will work for https for cPanel access. After changing the port, then run these two commands for it to take effect:

Code:
/usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings
/etc/init.d/httpd restart
I would suggest disabling non-secure cPanel and WHM access entirely, though. You can do that in WHM > Tweak Settings > Require SSL option by having it set to "On"

For WHM, I am not aware of an option to modify the WHM port, although it might be possible to setup iptables routing rules to do so.

Finally, for the /whm and /cpanel urls, you could remove those in /usr/local/apache/conf/httpd.conf file and distill it to preserve the changes. The lines will look similar to the following:

Code:
ScriptAliasMatch ^/?cpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?webmail/?$ /usr/local/cpanel/cgi-sys/wredirect.cgi
ScriptAliasMatch ^/?whm/?$ /usr/local/cpanel/cgi-sys/whmredirect.cgi
At that point, run the following to have the changes updated:

Code:
/usr/local/cpanel/bin/apache_conf_distiller --update
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
If you remove those options and change the cPanel port, then cPanel will only be accessible using the ports defined if proxy subdomains do not exist. If you remove the /whm option, then you will only be able to access WHM using the 2086 and 2087 ports, since those ports aren't changeable. You could, though, setup WHM > Host Access Control for whostmgrd and prevent access to WHM for any IP(s) other than your own.

I did want to mention one more point for the ScriptAliasMatch urls I mentioned above:

Code:
ScriptAliasMatch ^/?cpanel/?$ /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAliasMatch ^/?webmail/?$ /usr/local/cpanel/cgi-sys/wredirect.cgi
ScriptAliasMatch ^/?whm/?$ /usr/local/cpanel/cgi-sys/whmredirect.cgi
If you notice, the cPanel one uses redirect.cgi, the webmail one uses wredirect.cgi and the whm one uses whmredirect.cgi for the matching redirect. If you want to change the cpanel, webmail and whm urls, you can change them here to something else in httpd.conf and distill those changes. The only caveat is that you cannot get the cpanel one to work upon changing it if you've also changed the port number, so I simply suggest removing the cPanel redirection one if you will be changing the port number. You could, though, change the webmail and whm ones, so you end up with:

Code:
ScriptAliasMatch ^/?lisa/?$ /usr/local/cpanel/cgi-sys/wredirect.cgi
ScriptAliasMatch ^/?bart/?$ /usr/local/cpanel/cgi-sys/whmredirect.cgi
Then webmail will be available on domain.com/lisa and whm will be available on domain.com/bart instead for this example. You'd want to pick whatever works best for you.

Again, you'd then run these commands for that to take effect:

Code:
/usr/local/cpanel/bin/apache_conf_distiller --update
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
 

declops

Registered
Jan 30, 2015
1
0
1
cPanel Access Level
Reseller Owner
If you want to change the cpanel, webmail and whm urls, you can change them here to something else in httpd.conf and distill those changes. The only caveat is that you cannot get the cpanel one to work upon changing it if you've also changed the port number, so I simply suggest removing the cPanel redirection one if you will be changing the port number. You could, though, change the webmail and whm ones, so you end up with:

Code:
ScriptAliasMatch ^/?lisa/?$ /usr/local/cpanel/cgi-sys/wredirect.cgi
ScriptAliasMatch ^/?bart/?$ /usr/local/cpanel/cgi-sys/whmredirect.cgi
Then webmail will be available on domain.com/lisa and whm will be available on domain.com/bart instead for this example. You'd want to pick whatever works best for you.

Again, you'd then run these commands for that to take effect:

Code:
/usr/local/cpanel/bin/apache_conf_distiller --update
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
Can these changes be made to work for a specific domain/account, without affecting the rest of the domains/accounts which are hosted in the same IP? I would like to hide/remove the cpanel and whm redirects from one specific domain name but without it affecting any of the other accounts.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,260
463
Can these changes be made to work for a specific domain/account, without affecting the rest of the domains/accounts which are hosted in the same IP? I would like to hide/remove the cpanel and whm redirects from one specific domain name but without it affecting any of the other accounts.
Hello :)

Please let us know if this thread helps:

possible to disable domain.com/cpanel for client?

Thank you.