You already installed CyberPanel and your clients are accessing your webmail through https://serverdomain.com/snappymail .
However, you want your users to easily remember the webmail link through a fully qualified domain name such as https://webmail.serverdomain.com .
Follow the following steps:
Create a Website for the domain webmail.serverdomain.com
Go to https://serverdomain.com/websites/webmail.serverdomain.com
Under configurations click on Rewrite Rules
Select a template: Force HTTP → HTTPS
You will end up with this result:
### Rewrite Rules Added by CyberPanel Rewrite Rule Generator
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
### End CyberPanel Generated Rules.
Add a proxy rewrite for SnappyMail to webmail.serverdomain.com . The final result will be:
### Rewrite Rules Added by CyberPanel Rewrite Rule Generator
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
### End CyberPanel Generated Rules.
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^$ https://serverdomain.com/snappymail? [R=301,L,NC]
Click on Save rewrite rules Now you can access webmail via https://webmail.serverdomain.com
Learn more:
Many of the users have asked about removing port 8090 so that they can visit CyberPanel on a plain domain like panel.cyberpanel.net . However, normally this is not possible because port 8090 is hardcoded into to LSCPD server which powers CyberPanel. (Hardcoded configurations are used to improve performance)
Step 1: Create a Website for Hostname
First, you need to decide the domain on which you want to access CyberPanel without the port being appended to it. We are going to use https://switch.cy…
I used these rewrite rules in CyberPanel, but it did not work. I used the LiteSpeed admin and got a white page when opening webmail.domain.com .
The same happens when I want to install snappymail directly on a subdomain, setup.php gives a blank page.
I also have this line in CyberPanel when creating rewrite rules, do I need to delete it?
cat: /home/domain.com/webmail.domain.com/.htaccess: No such file or directory
@mrEckendonk Do not enable rewrite maps handled by CyberPanel. You do not need to do anything on OLS webadmin console.
Use the steps I wrote. If you get any errors post here I will help
I followed the steps, create a website (not a subdomain) webmail.domain.com
domain.com DNS is pointed to a project hosted on Vercel.
When I want to access the webmail.domain.com it get redirected to Not Found - René | Project Management Software (domain.com) , the project on Vercel.
@mrEckendonk
If your domain is hosted with Vercel it is managed by Vercel and cannot be used by CyberPanel in any way whatsoever.
For this tutorial to work for you, the domain has to point to a server either directly on CyberPanel or through DNS managed by CloudFlare and server should be running cyberpanel
https://community.cyberpanel.net/uploads/default/original/2X/4/485d6add4f5b50ed575c5513bdd9622c600bcbbe.png
You tried following the reference for changing rewrite rules by usman - i have removed that reference. The steps to rewrite domain rules are mentioned here
josephgodwinke:
DNS is managed by CloudFlare .
Maybe I should host the code on the CyberPanel instead, but lose performance. On a git push I have to upload the production code again.
I use the correct rewrite rules
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
### End CyberPanel Generated Rules.
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^$ https://domain.com/snappymail? [R=301,L,NC]
Should I use it with the subdomain instead?
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^$ https://webmail.domain.com/snappymail? [R=301,L,NC]
@mrEckendonk
For Setting up a Domain not Subdomain
You already installed CyberPanel and your clients are accessing your webmail through https://serverdomain.com/snappymail .
However, you want your users to easily remember the webmail link through a fully qualified domain name such as https://serverdomain.com .
To redirect to a domain:
Follow the following steps:
Create a Website for the domain serverdomain.com
Go to https://serverdomain.com/websites/serverdomain.com
Under configurations click on Rewrite Rules
Select a template: Force HTTP → HTTPS
### Rewrite Rules Added by CyberPanel Rewrite Rule Generator
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
### End CyberPanel Generated Rules.
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^$ https://panel.serverdomain.com/? [R=301,L,NC]
What does this mean?
QUERY_STRING - Match empty query in old url i.e exact page to page
Redirect 301 is a permanent redirect
L flag means if the rewrite rule matches, don’t process any more RewriteRules below this one.
NC flag means the rewrite rule to be matched in a case-insensitive manner
Hope this helps
Please keep CloudFlare as your DNS Manager so that you can continue enjoying the performance services they offer
I have used this tutorial for FQDN managed by CloudFlare, CyberPanel and other domain providers such as Namesilo
I uploaded the production build to the CyberPanel and made some progress.
Changed A record to point to the panel and used the rewrite rules.
A least, not getting the 404 from the original domain anymore, but the default 404 from CyberPanel.
I uploaded the production build to the CyberPanel and made some progress.
Changed A record to point to the panel and used the rewrite rules.
A least, not getting the 404 from the original domain anymore, but the default 404 from CyberPanel.
[image]
Am sorry but you are mixing up two issues here.
Kindly use your .com FDQN to setup a redirect for snappymail but you cannot use same domain for your vercel migrated website. Use a subdomain instead. A suitable name would be webmail.myverceldomain.com
The FQDN is not anymore on Vercel. The A record is the IP of the server.
Here is a screenshot of the CyberPanel with the rewrite rules
Oh now i understand you.
I can assume you have switch-panel.myserverdomain.com where snappymail should be at switch-panel.myserverdomain.com/snappymail
Now I see you created webmail.myvercelwebsite.com . This will need you to have the following rewrite rules on webmail.myvercelwebsite.com since this where we want to redirect:
### Rewrite Rules Added by CyberPanel Rewrite Rule Generator
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
### End CyberPanel Generated Rules.
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^$ https://switch-panel.myserverdomain.com/snappymail? [R=301,L,NC]
Tested and it works
I’m very sorry to inform you that the rewrite rules are not working.
Now I get the default page 404 on webmail.myvercelwebsite.com ,
josephgodwinke:
### Rewrite Rules Added by CyberPanel Rewrite Rule Generator
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
### End CyberPanel Generated Rules.
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^$ https://switch-panel.myserverdomain.com/snappymail? [R=301,L,NC]
The rules below fixed the issue a bit.
### Rewrite Rules Added by CyberPanel Rewrite Rule Generator
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
### End CyberPanel Generated Rules.
RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^$ https://switch-panel.myserverdomain.com:8443/snappymail? [R=301,L,NC]
I needed to add port 8443 to avoid the 404 and Snappymail starts to load but won’t complete loading. The Loader keeps spinning.
This is the same issue as running it directly within access webmail link in CP after changing the port due to Cloudflare blocking the default port.
Remember this port is not optimnized for performance by cloudflare
the default 8090 is blocked on Cloudflare, 8443 works fine for CyberPanel, but after 5 minutes, SnappyMail is still loading.
Any suggestion for a better port, or use another open-source webmail?
I do not understand what you want to achieve kindly help me understand.
I use the above method for all my clients. This is default setup and no one has ever complained. Its just a redirect which helps them remember the webmail link.
I have tested an FQDN whose DNS is managed by CloudFlare. I added an A record for switch-panel.myserverdomain.com which runs on port 8090 i.e
A → switch-panel → server_ip → AUTO (ttl)
Cloudflare is not complaining about any port. Redirect runs as expected
@josephgodwinke Thanks for all your effort to give support. Finally, it works.
I restarted to follow this guide, How to remove port 8090 from CyberPanel , and noticed a simple issue. I had the panel proxied on Cloudflare.
Afterward, following your rewrite rules, it worked out of the box.
Thanks again!
@josephgodwinke Thanks for the tutorial!
I followed your guide but every time I visit mail.mysite.com then I get redirected to https://panel.mysite.com:8090/snappymail/#/mailbox/INBOX
Is there any way to stay on the same mail subdomain (mail.mysite.com ) without redirecting to snappymail folder? I have multiple websites on the same server and I need to have a separate mail* subdomain for each site (mail.mysite.com ) . Otherwise all clients will use my main server’s snappymail URL to log in.
Any wise advice would be highly appreciated!