Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Forcing .cpanel .whm and .webmail subdomains to server hostname w/ SSL

Discussion in 'Workarounds and Optimization' started by jrquint, Jun 12, 2014.

  1. jrquint

    jrquint Registered

    Joined:
    Mar 30, 2012
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    51
    cPanel Access Level:
    Root Administrator
    We've had quite a few customers get accustomed to accessing their accounts via the cpanel.(domain.com) and webmail.(domain.com). For obvious reasons we force SSL on these subdomains (tweak settings) as they're passing login information through them. The issue with this is that they all get certificate errors as cPanel will use the server's hostname SSL certificate. This worries quite a few users and we've gotten a few complaints.

    Since I don't see any option to have the subdomains redirected to the HOSTNAME.com:2083, etc in tweak settings (like you can do for domain.com/cpanel) came up with this procedure to modify the httpd.conf to force this redirect:



    # cp /var/cpanel/templates/apache2_4/main.default /var/cpanel/templates/apache2_4/main.local

    # nano /var/cpanel/templates/apache2_4/main.local

    replace (2 locations) :

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^[% wildcard_safe(servername) %]$
    RewriteCond %{HTTP_HOST} ^cpanel\.
    RewriteRule ^/(.*) http://127.0.0.1:2082/$1 [P]

    RewriteCond %{HTTP_HOST} !^[% wildcard_safe(servername) %]$
    RewriteCond %{HTTP_HOST} ^webmail\.
    RewriteRule ^/(.*) http://127.0.0.1:2095/$1 [P]

    RewriteCond %{HTTP_HOST} !^[% wildcard_safe(servername) %]$
    RewriteCond %{HTTP_HOST} ^whm\.
    RewriteRule ^/(.*) http://127.0.0.1:2086/$1 [P]

    with:


    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^webmail\.* [OR]
    RewriteCond %{HTTP_HOST} ^www\.webmail\.*
    RewriteRule ^/?$ "https\:\/\/hostname\.com\:2096" [R=301,L]

    RewriteCond %{HTTP_HOST} ^cpanel\.* [OR]
    RewriteCond %{HTTP_HOST} ^www\.cpanel\.*
    RewriteRule ^/?$ "https\:\/\/hostname\.com\:2083” [R=301,L]

    RewriteCond %{HTTP_HOST} ^whm\.* [OR]
    RewriteCond %{HTTP_HOST} ^www\.whm\.*
    RewriteRule ^/?$ "https\:\/\/hostname\.com\:2087” [R=301,L]

    rebuild httpd.conf and restart apache:

    # /scripts/rebuildhttpdconf
    # /etc/init.d/httpd restart
     
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    44,724
    Likes Received:
    1,883
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello :)

    Thank you for sharing this workaround. Please note that user-submitted workarounds are not tested or supported by cPanel. We encourage everyone to review all aspects of workarounds before implementing them on a production server.

    Thank you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice