The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

new proxy subdomains & redirects

Discussion in 'General Discussion' started by Phylum, Dec 31, 2012.

  1. Phylum

    Phylum Active Member

    Joined:
    Apr 20, 2010
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    1
    I purchased an SSL cert and to keep things simple, email.tld is what the users should be using when configuring mail clients, and is the website they should use to access 'email via the web'.

    My objectives

    I'll start off by saying the built-in proxy subdomains (webmail, whm, cpanel etc) all worked fine; dns A (and CNAME) records exist as well.

    I made some slight modifications to httpd.conf....
    Code:
    ...
    ScriptAliasMatch ^/?email/?$ /usr/local/cpanel/cgi-sys/wredirect2.cgi
    ScriptAliasMatch ^/?mail/?$ /usr/local/cpanel/cgi-sys/wredirect2.cgi
    ...
    
    <VirtualHost ip1:80 ip1:443 ip2:443 ip2:80 ip3:443 ip3:80 127.0.0.1:80 *>
        ServerName hostname.tld
        ServerAlias cpanel.* whm.* mail.* email.* webmail.* webdisk.* autodiscover.* autoconfig.*
    ...
        RewriteCond %{HTTP_HOST} ^email\.
        RewriteCond %{HTTPS} on
        RewriteRule ^/(.*) https://127.0.0.1:2096/$1 [P]
        RewriteCond %{HTTP_HOST} ^mail\.
        RewriteCond %{HTTPS} on
        RewriteRule ^/(.*) https://127.0.0.1:2096/$1 [P]
        RewriteCond %{HTTP_HOST} ^email\.
        RewriteRule ^/(.*) http://127.0.0.1:2095/$1 [P]
        RewriteCond %{HTTP_HOST} ^mail\.
        RewriteRule ^/(.*) http://127.0.0.1:2095/$1 [P]
    ...
    </VirtualHost>
    
    ... then created wredirect2.cgi from wredirect.cgi and changed one thing in wredirect2.cgi: webmail to email
    Code:
        service => ( $zero =~ /whm/ ? 'whm' : ( $zero =~ /^w|\s+w/ ? 'email' : 'cpanel' ) )
    

    The above works. I tested the 2 new subdomains and it successfully loads the webmail login screen. And of course https://webmail.tld still works. So great, almost there.

    To help prevent user confusion due to the domain mismatch SSL warnings, I want to redirect http & https requests for webmail.tld and email.tld to https://email.tld [over port 443].

    I was thinking of something like this. But perhaps I should be doing this differently; in a way that doesn't require hard coding the domain into httpd.conf?
    Code:
    ...
    
    <VirtualHost ip1:80 ip1:443 ip2:443 ip2:80 ip3:443 ip3:80 127.0.0.1:80 *>
        ServerName hostname.tld
        ServerAlias cpanel.* whm.* mail.* email.* webmail.* webdisk.* autodiscover.* autoconfig.*
    ...
        RewriteCond %{HTTP_HOST} ^webmail\.
        RewriteCond %{HTTPS} on
        RewriteRule ^/(.*) https://email.tld/$1 [P]
        RewriteCond %{HTTP_HOST} ^webmail\.
        RewriteRule ^/(.*) http://email.tld/$1 [P]
    ...
    </VirtualHost>
    
     
Loading...

Share This Page