Redirect webmail.domain.com to webmail.domain.com:2096

Mise

Well-Known Member
May 15, 2011
64
3
58
I have read the related threads but no answer.

I cannot redirect http(s)://webmail.domain.com and http(s)://domain.com/webmail to .

Or in case that's not possible, then redirect to https://domain.com:2096/


This is my configuration:

- Service subdomains
Add proxy VirtualHost to httpd.conf to automatically redirect unconfigured cpanel, webmail, webdisk, cpcalendars, cpcontacts, and whm subdomains to the correct port (requires mod_rewrite, mod_headers, and mod_proxy)
Off

- Redirection
Choose the closest matched domain for which that the system has a valid certificate when redirecting from non-SSL to SSL URLs. Formerly known as “Always redirect to SSL/TLS”
Off

- Non-SSL redirect destination
Origin Domain Name

- SSL redirect destination
SSL Certificate Name default

- Security
Require SSL for cPanel Services
On


Problem is some users believes it is domain.com/webmail, while others believes webmail.domain.com

I need to redirect all Webmail URL (http or httpS) to only one URL:2096,


Now I have http(s)://domain.com/webmail which redirects to https://domain.com:2096/. Although http(s)://webmail.domain.com do nothing.


What are the needed options?
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
7,418
1,001
313
cPanel Access Level
Root Administrator
Hey there! By default, I would expect both of those to work normally on the machine without any customization as those are built-in features of the cPanel tools.

Do you have anything else set up that might be interfering with this behavior, such as customizations to Apache or tools like Cloudflare?
 

Mise

Well-Known Member
May 15, 2011
64
3
58
hi!. No, I dont' have cloudflare or apache personalizations.
Server and CPanel install is new.

I would be grateful for any help. Maybe some WHM option interfers?
 

Mise

Well-Known Member
May 15, 2011
64
3
58
ok, its partially solved. It works showing the CPanel to choose between :2093 or :443

Although my intention was to limit the access to Cpanel services (webmail, etc) by country.

I try this inside WHM -> Apache -> includes (global pre-conf directive) although it doesn't work:

Code:
RewriteCond %{HTTP_HOST} ^.*(autoconfig|autodiscover|cpanel|cpcalendars|cpcontacts|webdisk|webmail|whm).* [NC,OR]
RewriteCond %{REQUEST_URI} ^.*(autoconfig|autodiscover|cpanel|cpcalendars|cpcontacts|webdisk|webmail|whm).*
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} !^(DE|CH|ES|IT|FR|)$
RewriteRule ^ 404 [END]
I have mod_geoip installed and working.

Is there some way to include these conditions inside the Apache pre-directives?