CyberPanel Community

Custom URL for Webmail

Ri
Rituraj #1

Hey I would like to redirect cyberpanel.domain.com/snappymail to something like webmail.domain.com

Earlier it used to work fine with redirect rules.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^webmail.domain.com$
RewriteRule ^(.*)$ HTTP://cyberpanel/rainloop/$1 [P]

Since when cyberpanel upgraded to Snappymail it doesn’t work and I get the following error:

An error occurred.
Please refresh the page and try again. Error: Failed loading /snappymail/snappymail/v/2.15.3/static/js/min/libs.min.js

Can someone please help me out!

55 replies
Sy
Syahran #3

Maybe this way can help you

RewriteEngine on
RewriteCond %{HTTP_HOST} ^webmail.domain.com$
RewriteRule ^(.*)$ HTTP://cyberpanel/$1 [P]
RedirectMatch ^/$ https://webmail.domain.com/snappymail
Ri
Rituraj #4

Just tried it. It redirects me to the Cyberpanel login instead of email.

Sy
Syahran #5

If you still want to use webmail.domain.com you can then follow the steps below:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^webmail.domain.com$
RewriteRule ^(.*)$ http://cyberpanel/snappymail/$1 [P]

after that go to terminal then type the following command:

# cp -r /usr/local/CyberCP/public/snappymail/snappymail/v /usr/local/CyberCP/public/snappymail/snappymail/snappymail/

maybe it’s a temporary solution that can be done so that it can run on webmail.domain.com

Ri
Rituraj #6

This gives the following error as before

An error occurred.
Please refresh the page and try again. Error: Failed loading /snappymail/snappymail/v/2.15.3/static/js/min/libs.min.js
SS
Sathish Sampath #7

Hi,
Anyone has a solution for this Error: Failed loading /snappymail/snappymail/v/2.15.3/static/js/min/libs.min.js

jo
josephgodwinke #8

Hello @zebrando Happy you are here

Go to /usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/configs/application.ini:

Under [logs], set enable = On.
Under [logs] you can also change level = 4 to show/hide some messages from the logs.
Under [labs], set use_app_debug_js = On

Post contents of nano /usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/logs.
Click F12 to open the console in your browser` and post contents of that log here

Ri
Rituraj #9


I don’t see anything for logs there.

SS
Sathish Sampath #11

Hi josephgodwinke,

above is the content in /usr/local/lscp/cyberpanel/rainloop/data/data/default/logs

jo
josephgodwinke #13

Run nano /snappymail/snappymail/v/2.15.3/static/js/min/libs.min.js post result here

jo
josephgodwinke #14

There must be a problem with your installation because that file should be present there

webmail.zebrando.com/:1 Refused to apply style from 'https://webmail.zebrando.com/snappymail/snappymail/v/2.15.3/static/css/app.min.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
/snappymail/snappymail/v/2.15.3/static/js/libs.js:1          Failed to load resource: the server responded with a status of 404 ()
webmail.zebrando.com/:1 Refused to execute script from 'https://webmail.zebrando.com/snappymail/snappymail/v/2.15.3/static/js/libs.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
(index):73 Uncaught (in promise) Error: Failed loading /snappymail/snappymail/v/2.15.3/static/js/libs.js
    at script.onerror ((index):73:34)
/snappymail/snappymail/v/2.15.3/static/apple-touch-icon.png:1          Failed to load resource: the server responded with a status of 404 ()
manifest.json:1          Failed to load resource: the server responded with a status of 404 ()
manifest.json:2 Manifest: Line: 2, column: 1, Syntax error.
webmail.zebrando.com/:1 Refused to apply style from 'https://webmail.zebrando.com/snappymail/snappymail/v/2.15.3/static/css/app.min.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
manifest.json:1          Failed to load resource: the server responded with a status of 404 ()

How did you manage to change your installation like this?

Ri
Rituraj #15

jo
josephgodwinke #16

Undo all the rewrites you did for snappymail I see above

Ri
Rituraj #17

I did them in a trial server so the main server is untouched

jo
josephgodwinke #18

Run nano /usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/configs/application.ini:

[labs]
imap_folder_list_limit = 0
autocreate_system_folders = On
[logs]
enable = On
level = 4

Post contents of nano /usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/logs/log-2022-10-29.txt

jo
josephgodwinke #20

Try this version changer and choose v2.15.3

sh <(curl https://raw.githubusercontent.com/josephgodwinkimani/cyberpanel-mods/main/snappymail_v_changer.sh || wget -O - https://raw.githubusercontent.com/josephgodwinkimani/cyberpanel-mods/main/snappymail_v_changer.sh)

Then follow these steps Custom URL for Webmail - #18 by josephgodwinke

Ri
Rituraj #21

I tried to do all that and access webmaill.domain.com but doesn’t look like it logged anything.

jo
josephgodwinke #22

I didnt want you to execute an overhaul but here it is:

$ rm -rf /usr/local/CyberCP/public/snappymail
$ sh <(curl https://raw.githubusercontent.com/josephgodwinkimani/cyberpanel-mods/main/snappymail_v_changer.sh || wget -O - https://raw.githubusercontent.com/josephgodwinkimani/cyberpanel-mods/main/snappymail_v_changer.sh)
FR
Fadi Ramadan #23

wait you updated snappymail? so if i run this version update on the server it should work?

jo
josephgodwinke #24

Welcome @Murex Happy you are here

if you do not have any technical ability I do not advice you upgrade snappymail if it works perfectly with standard cyberpanel installation.

The upgrade will not cause any issues unless there are unknown issues with latest release. Also I advice my clients not use any latest releases of any software for production.

FR
Fadi Ramadan #25

hello, i’m getting the same issues the OP, and trying to solve it , so far only webmailDOTdomainDOTcom/snappymail redirects properly and i’m trying to remove that last bit , tried another redirect from webmail.domain.com to webmailDOTdomainDOTcom/snappymail
and forsome strange reason it will not work! so i was wondering if this is only because the cyberpanel version of snappy has an issue .

jo
josephgodwinke #26

CyberPanel’s version of snappymail is downloaded straight from the source during installation and it is not a modified version or anything.

I recommend that you guys don’t try to reverse proxy snappymail.

FR
Fadi Ramadan #27

I figured it out . after looking into the log I realized that the redirect link keeps going into snappymail/snappymail which is creating all the problems , the solution was editing the intial redirect to https to add /snappymail , like that .

RewriteRule ^/?(.*) https://%{SERVER_NAME}/snappymail/$1 [R,L]

so when the Proxy is taking the server name it applies snappymail right away hence
RewriteRule ^(.*)$ HTTP://cyberpanel/$1 [P]

this way it works and logs in
hope it helps the others.

jo
josephgodwinke #28

@Murex no that would not work. See this

This should work. This is the solution.

FR
Fadi Ramadan #29

Thanks a lot for your time! i’ve never seen such awesome support and community before!

your solution works like a redirect. basically people will put their mail. address and then get redirected to the cyberpanel main address with snappy
meaning if they put mailDOTdomainDOTcom they will see on the address bar
CyberpanelDOTserverdomainDOTcom/snappymail/
which is not the intended outcome.
i was thinking of setting up another proxy to mask the cyberpanel main domain page . however the solution i provided earlier is satisfying , i dont want the server domain to show up.
thats why i’m still using the proxy that was set up to cover the 8090 port

jo
josephgodwinke #30

@Murex post your rewrite rules I revert if it works as intended

FR
Fadi Ramadan #31

hello again, thanks again for all your help

so i set up the rewrite rules as so

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/snappymail/$1 [R,L]

RewriteCond %{HTTP_HOST} ^webmail.domainname.com$
RewriteRule ^(.*)$ HTTP://cyberpanel/$1 [P]

keep in mind that the above code handles everything, because I changed the rewrite code from cyber panel
these ones

Rewrite Rules Added by CyberPanel Rewrite Rule Generator

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

End CyberPanel Generated Rules.

keep in mind that I followed this tutorial before remove port 8090

jo
josephgodwinke #32

My friend this part will redirect to admin panel:

RewriteCond %{HTTP_HOST} ^webmail.domainname.com$
RewriteRule ^(.*)$ HTTP://cyberpanel/$1 [P]
FR
Fadi Ramadan #33

it wont because i already kept snappymail in the original redirect .here
RewriteRule ^/?(.*) https://%{SERVER_NAME}/snappymail/$1 [R,L]

so . webmail.domainname.com is redirecting to https webmail domainname com / snappymail

then its checks http_host for webmail.domainname.com and proxy it with the cyberpanelproxy which we set up server side

and so it takes you to webmail.domainname.com/snappymail
its working as intended … i’m using it as we speak

SA
Said Ali #35

Here is the log that shows this error…

[2022-12-19 19:34:25.660][af79299e] INFO[DATA]: [DATE:2022-12-19 UTC][SM:2.15.3][IP:192.168.15.254][PID:92997][LiteSpeed][litespeed][Streams:tcp,udp,unix,udg,ssl,tls,tlsv1.0,tlsv1.1,tlsv1.2,tlsv1.3]
[2022-12-19 19:34:25.660][af79299e] REQUEST[NOTE]: [GET] https://mail.mydomain.com/snappymail/
[2022-12-19 19:34:25.689][af79299e] INFO[MEMORY]: Memory peak usage: 2MB
[2022-12-19 19:34:25.689][af79299e] INFO[TIME]: Time delta: 0.07535195350647

[2022-12-19 19:34:27.169][b0f025b2] INFO[DATA]: [DATE:2022-12-19 UTC][SM:2.15.3][IP:192.168.15.254][PID:92997][LiteSpeed][litespeed][Streams:tcp,udp,unix,udg,ssl,tls,tlsv1.0,tlsv1.1,tlsv1.2,tlsv1.3]
[2022-12-19 19:34:27.169][b0f025b2] REQUEST[NOTE]: [GET] https://mail.mydomain.com/snappymail/?/AppData/0/17282663328686265/
[2022-12-19 19:34:27.171][b0f025b2] APPDATA[DATA]: rl.initData({“Auth”:false,“AccountHash”:“”,“AccountSignMe”:false,“MailToEmail”:“”,“Email”:“”,“DevEmail”:“”,“DevPassword”:“”,“Title”:“SnappyMail Webmail”,“LoadingDescription”:“SnappyMail”,“FaviconUrl”:“”,“LoginDefaultDomain”:“”,“hideSubmitButton”:false,“DetermineUserLanguage”:true,“DetermineUserDomain”:true,“SieveAllowFileintoInbox”:false,“ContactsIsAllowed”:false,“Admin”:,“Capa”:,“Plugins”:,“System”:{“version”:“2.15.3”,“admin”:false,“token”:“ae193d0888b7f9a0aebe8aa0abff51f46d6ccfd4”,“inIframe”:false,“allowHtmlEditorBitiButtons”:false,“allowCtrlEnterOnCompose”:true,“useImapThread”:true,“allowAppendMessage”:false,“folderSpecLimit”:50,“listPermanentFiltered”:false,“themes”:[“Default”,“A”,“Blurred”,“DarkShine”,“Linen”,“Love”,“Snow”,“SnowDarkV1”,“Squares”,“SquaresDark”,“Stripes”,“Wood”,“Xv”,“Clear”],“languages”:[“ar-SA”,“bg-BG”,“cs-CZ”,“da-DK”,“de-DE”,“el-GR”,“en”,“en-US”,“es-ES”,“et-EE”,“fa-IR”,“fi-FI”,“fr-FR”,“hu-HU”,“id-ID”,“is-IS”,“it-IT”,“ja-JP”,“ko-KR”,“lt-LT”,“lv-LV”,“nb-NO”,“nl-NL”,“pl-PL”,“pt-BR”,“pt-PT”,“ro-RO”,“ru-RU”,“sk-SK”,“sl-SI”,“sv-SE”,“tr-TR”,“uk-UA”,“zh-CN”,“zh-TW”],“languagesAdmin”:[“cs-CZ”,“da-DK”,“de-DE”,“en”,“es-ES”,“fa-IR”,“fi-FI”,“fr-FR”,“hu-HU”,“id-ID”,“it-IT”,“ja-JP”,“lt-LT”,“nb-NO”,“nl-NL”,“pl-PL”,“pt-BR”,“ru-RU”,“sk-SK”,“sl-SI”,“sv-SE”,“zh-CN”],“attachmentsActions”:[“zip”],“customLogoutLink”:“”},“NewMoveToFolder”:true,“AllowLanguagesOnSettings”:true,“AllowLanguagesOnLogin”:true,“AttachmentLimit”:2097152,“SignMe”:“DefaultOff”,“UseLocalProxyForExternalImages”:true,“ViewHTML”:true,“ShowImages”:false,“RemoveColors”:false,“MessagesPerPage”:20,“MessageReadDelay”:5,“SoundNotification”:true,“NotificationSound”:“new-mail”,“DesktopNotifications”:true,“Layout”:1,“EditorDefaultType”:“Html”,“UseCheckboxesInList”:true,“AutoLogout”:30,“UseThreads”:false,“AllowDraftAutosave”:true,“ReplySameFolder”:false,“ContactsAutosave”:true,“HideUnsubscribed”:false,“MainEmail”:“”,“KolabContactFolder”:“”,“UserBackgroundName”:“”,“UserBackgroundHash”:“”,“AdditionalLoginError”:“”,“Theme”:“Default”,“Language”:“en-US”,“UserLanguage”:“en-US”,“PluginsLink”:“”,“StaticLibsJs”:“/snappymail/snappymail/v/2.15.3/static/js/min/libs.min.js”});
[2022-12-19 19:34:27.171][b0f025b2] INFO[MEMORY]: Memory peak usage: 2MB
[2022-12-19 19:34:27.171][b0f025b2] INFO[TIME]: Time delta: 0.0051159858703613

jo
josephgodwinke #36

Welcome @saidearly Happy you are here

Run

sh <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh || wget -O - https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh)

If using a sudo user rather than root, try this:

sudo su - -c "sh <(curl https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh || wget -O - https://raw.githubusercontent.com/usmannasir/cyberpanel/stable/preUpgrade.sh)"

SA
Said Ali #37

Already on the latest release. I have even done fresh installation couple times. But the error is the same.

jo
josephgodwinke #38

Run

$ rm -rf /usr/local/CyberCP/public/snappymail
$ rm -rf /usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/configs

# RUN CYBERPANEL UPGRADE AS IT WILL DO EVERYTHING FOR YOU
# run the rest if you want to personalize (not recommended for beginners)

$ wget https://github.com/the-djmaze/snappymail/releases/download/v2.17.0/snappymail-2.17.0.zip
$ unzip snappymail-2.17.0.zip -d /usr/local/CyberCP/public/snappymail
$ cd /usr/local/CyberCP/public/snappymail
$ find . -type d -exec chmod 755 {} \;
$ find . -type f -exec chmod 644 {} \;
$ mkdir -p /usr/local/lscp/cyberpanel/rainloop/data
$ mkdir -p /usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/configs/
$ mkdir snappymail configs
$ cat << EOF >> /usr/local/lscp/cyberpanel/rainloop/data/_data_/_default_/configs/application.ini
[labs]
imap_folder_list_limit = 0
autocreate_system_folders = On
EOF
$ cat << EOF >> /usr/local/CyberCP/public/snappymail/snappymail/v/2.17.0/include.php
$sCustomDataPath = '/usr/local/lscp/cyberpanel/rainloop/data';
EOF
# you will need to comment out any other $sCustomDataPath = before the one we appended above
$ cat << EOF >> /usr/local/CyberCP/public/snappymail/_include.php
define('APP_DATA_FOLDER_PATH', '/usr/local/lscp/cyberpanel/rainloop/data/');
EOF
$ cat << EOF >> /usr/local/CyberCP/public/snappymail/include.php
define('APP_DATA_FOLDER_PATH', '/usr/local/lscp/cyberpanel/rainloop/data/');
EOF
$ mkdir snappymail configs
$ sed -i 's|autocreate_system_folders = Off|autocreate_system_folders = On|g' 2.17.0
SA
Said Ali #39

Followed your direction with Cyberpanel upgrade. Results = same error after upgrade.

Then I tried manual process following you steps
and getting the errors at the end

root@trahezy:/usr/local/CyberCP/public/snappymail# mkdir snappymail configs
mkdir: cannot create directory ‘snappymail’: File exists
mkdir: cannot create directory ‘configs’: File exists
root@trahezy:/usr/local/CyberCP/public/snappymail# sed -i ‘s|autocreate_system_folders = Off|autocreate_system_folders = On|g’ 2.17.0
sed: can’t read 2.17.0: No such file or directory

I switched into the directory v where 2.17.0 directory is located and got this
root@trahezy:/usr/local/CyberCP/public/snappymail/snappymail/v# sed -i ‘s|autocreate_system_folders = Off|autocreate_system_folders = On|g’ 2.17.0
sed: couldn’t edit 2.17.0: not a regular file

jo
josephgodwinke #40

Did you remove the previous snappymail installation v2.18.6 as i advised above?

SA
Said Ali #41

Yes. I did. I just repeated again the process and after cyberpanel upgrade. i did snappymail version change to 2.17.0.
Got same error

SA
Said Ali #43

No. Not really getting that error.
Accessing the snappymail through cybepanel domain/snappymail works but using its dedicated subdomain is the issue
Example:

cyberpaneldomaincom/snappymail = working
maildomaincom = the error

RewriteRules

Rewrite Rules Added by CyberPanel Rewrite Rule Generator

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.)$
RewriteRule ^(.
)$ http://%1/$1 [L,R=301]
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.) https://%{SERVER_NAME}/$1 [R,L]
RewriteRule ^(.
)$ https://cyberpanel/snappymail/$1 [P]

End CyberPanel Generated Rules.

jo
josephgodwinke #44

SHould not work since cyberpanel creates or any other panel create a mailserver from that domain. You need to add something like webmail.myprimarydomain.com

If you look at the post you will see he/she ran into this issue:

SA
Said Ali #45

Doesn’t work with webmaildomaincom that was just example.
Try to do clean install of cyberpanel and do the webmaildomaincom to reproduce the issue.

by the way
Even though the maildomaincom is used by mailserver ports for webserver are not on mailserver so web access to the maildomaincom should work fine without issue. Just a highlight.

SA
Said Ali #46

Refreshed and cleared cache and tried a new browser all go back to same error

jo
josephgodwinke #47

Are you in a position to reinstall your server os and start over? If so share your server os type and version

EB
Eros Bruno #48

Good evening, I don’t know if you are still interested, but to do the proxy correctly I solved it this way. I hope it can be the help to someone!

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

www.example.com should be replaced with the correct host.

SA
Said Ali #49

Already installed like 5 times ending up with the same results.

SA
Said Ali #50

Hi,
Thanks for your contribution,

Your configuration works super smooth.

Thanks mate.

You all be blessed.

EB
Eros Bruno #51

I am very pleased! Always at your disposal. :grinning:

FC
Franklin Casco #52

Hi
Where i put this code?

This is for each domain?

Ri
Rituraj #53

Hey, Thanks for the input. It works flawlessly. Although after doing this I can’t login through webmail anymore. i am getting error “Server message: Cannot enable STARTTLS.”

Any Idea how to resolve this?

Co
Cookie #54

Heya, i am very very new to CyberPanel and still havent figured out most things, i would like to know how exactly i can change the login for the webmain, i have bought my domain through CF and i dont have a problem with the CyberPanel login being ip:port, but since i am offering webmail access to my friends and them having to go to ip:port/snappymail isnt that great for them since their home network has strict rules and they cannot connect to plain IP adresses, i would like to know how i can change the snappymail login thing to webmail.mydomain.tld, i have tried nearly everything that was suggested in the replys above but nothing has worked, thanks in advance for taking your time to help a noobie out

Pi
Pierre #55

@KingMac , Amazing Tip. Work Just Fine!!!

Thanks

FR
Fadi Ramadan #56

amazing work bro!!! i just came back to this thread and wow . love your solution!

FR
Fadi Ramadan #57

I don’t think is this a problem with the proxy kingmac wrote. this is probably due to your mail ssl . either way to help others perhaps click solution on kingmac’s answer , so that others can find this solution quick!

No
Nourin #58

Where to add this?

Sign in to reply