Access Webmail (Snappy Mail) from subdomain and without port (e.g. https://webmail.example.com)

Step 1: Create a Website e.g. webmail.example.com

First, you need to decide the domain on which you want to access Web Mail without the port being appended to it. We are going to use https://webmail.example.com

Please make sure that A record of this domain already points towards your server.

Setup Web Mail without port (OpenLiteSpeed)

Open command line and edit:

nano /usr/local/lsws/conf/httpd_config.conf

Paste following content:

extprocessor webmail {
  type                    proxy
  address                 https://webmail.example.com:8090
  maxConns                100
  pcKeepAliveTimeout      60
  initTimeout             60
  retryTimeout            0
  respBuffer              0
}

Please replace https://webmail.example.com:8090 with the domain you choose in Step 1.

Use Rewrite Rules to Proxy to port 8090

You can now use rewrite rules to proxy traffic to port 8090, now edit rewrite rules for the domain you choose in Step 1 using the rewrite rule guide. You can use these rules:

RewriteCond %{REQUEST_URI} !^/snappymail
REWRITERULE ^(.*)$ https://webmail/snappymail/$1 [P,L,E=PROXY-HOST:webmail.example.com]
RewriteCond %{REQUEST_URI} ^/snappymail
REWRITERULE ^(.*)$ https://webmail/$1 [P,L,E=PROXY-HOST:webmail.example.com]

Once done restart OpenLiteSpeed with this command:

systemctl restart lsws

You can now visit Web Mail on your domain https://webmail.example.com.

1 Like

works on Litespeed?

Pretty much works with slight adjustments: How to remove port 8090 from CyberPanel