How to configure custom apache redirects in Centos WebPanel (CWP)

Most times server admins would like to have users redirected to specific URLs when accessing the server. One example is when accessing a control panel login page. A good security standard is to ensure that all logins to your servers are done via SSL connections. This automatically adds a layer of security for your users logins. Some control web panels implement this during installation.

For Centos Webpanel, they provide both SSL and non-SSL logins. You may want to disable or reduce the non-SSL login links and have them redirected to SSL. Let’s see how we do this.

First, take note of the following ports used in CWP:

– Admin control panel SSL port: 2031 or 2087

– Admin control panel non-SSL port: 2030 or 2086

– User control panel SSL port: 2083

– User control panel SSL port: 2082

Procedure

1. Ensure you have SSL for the hostname. You can install Free Let’s Encrypt SSL or Install Premium SSL for the hostname

2. Login to CWP as root and navigate to WebServer Settings >> Apache Redirects

3. You will see a list of redirects settings displayed. You can add new redirects as well as edit or delete existing ones as needed. Here is a summary of default redirects.

  • /cwp , /cpanel, /kpanel, /scwp, /isp, /controlpanel, /securecontrolpanel are all redirects used for user control panel login
  • /whm /securewhm are redirects used for admin control panel login
  • /pma, /phpmyadmin, /myadmin are redirects for phpMyAdmin

4. Basically, these are the ones you’ll be removing or editing. Remove all but one IP logins as Ips dont redirect to SSL. Let all your logins be performed on the hostname. (Maybe leave one non-SSL login just incase there’s something wrong with your SSL and you badly need to login. However, you can remove all non-SSL and if there is something wrong with your SSL, edit the redirects config file as via SSH to accommodate non-SSL login as you sort out the issue)You can configure few logins for the four critical areas as follows:

  • user control panel: Use /cpanel, /cwp, /cp to redirec to 2083
  • admin control panel: Use /whm to redirect to port 2031
  • webmail login: /webmail
  • phpMyAdmin login: /pma

5. Once through, navigate to the dashboard and restart apache

That should be all. In case you want to add any custom redirects, this is where you do it.

And of course, all this can be done via the SSH by simply editing the the config file:

/usr/local/apache/conf.d/system-redirects.conf

Then restart apache:

systemctl
restart httpd

To sum it up, here is a list of my redirects

Redirect permanent /myadmin
https://serv2.rawle.systems:2031/pma

Redirect permanent /MyAdmin
https://serv2.rawle.systems:2031/pma

Redirect permanent /phpmyadmin
https://serv2.rawle.systems:2031/pma

Redirect permanent /phpMyAdmin
https://serv2.rawle.systems:2031/pma

Redirect permanent /kpanel
http://167.114.169.229:2030/

Redirect permanent /cwp
http://167.114.169.229:2082/

Redirect permanent /isp
http://167.114.169.229:2030/

Redirect permanent /cpanel
https://serv2.rawle.systems:2083

Redirect permanent /scwp
https://serv2.rawle.systems:2083

Redirect permanent /controlpanel
http://167.114.169.229:2082/

Redirect permanent /securecontrolpanel
https://serv2.rawle.systems:2083

Redirect permanent /securewhm
https://serv2.rawle.systems:2031

Redirect permanent /whm
https://serv2.rawle.systems:2031

Leave a Reply

Your email address will not be published.