Roundcube Community Forum

 

Cloudflare 524 Error with Roudcube

Started by peaceharbor, May 04, 2024, 11:51:03 AM

Previous topic - Next topic

peaceharbor

There is an issue between the Cloudflare DNS proxy of the webmail record (either A or CNAME) and accessing the Roundcube Inbox directly. When trying to reach a client's mailbox via https://webmail.domain.com, the page will load with SSL as it should. Whenever you try to log in, the page will try to load until it eventually gives a Cloudflare 524 timeout.

If you just set up a new mailbox account and log in for the first time, you can access the mail account configuration page, but once you try to enter the Roundcube mailbox, you will encounter the same issue as above.

On the other hand, if accessing the same mail account through WHM, which is not proxied via Cloudflare, Roundcube loads without issue. I have spent several days working with the tech team at my data center (LiquidWeb), and they are also seeing the same problem. They have ruled out conflicts except those between Cloudflare and Roundcube playing nicely.

This issue has also reached the Cloudflare forums, but a resolution has yet to be brought to light.

https://community.cloudflare.com/t/roundcube-524-a-timeout-occurred/485616/6
https://community.cloudflare.com/t/webmail-time-out/369911/4
https://community.cloudflare.com/t/mail-timeout-after-activated-cloudflare/325753
https://community.cloudflare.com/t/cpanel-webmail-after-login-does-not-load-and-gives-error-524/523763
https://community.cloudflare.com/t/cpanel-webmail-fatal-error-or-timeout-occurred-while-processing-this-directive/631322

Hopefully, someone at Roundcube can fix this issue, as the only option is to disable the proxy on the A or CNAME record. Here's a short video showing this in further detail that I also sent to my data center. https://share.peaceharbor.com/NQuAdEod

I opened a ticket on Roundcube's Github here: https://github.com/roundcube/roundcubemail/issues/9436

SKaero

This isn't a Roundcube issue. I have Roundcube installed behind a Cloudflare DNS proxy and it works fine. I believe this is a cPanel issue, there is a recent thread on there forum indicating that they are aware of a issue and are working to address it: https://support.cpanel.net/hc/en-us/community/posts/23150240197399-RoundCube-Not-Loading

peaceharbor

Thanks for the insight. This comment made by this user on that thread was particularly interesting: https://support.cpanel.net/hc/en-us/community/posts/23150240197399/comments/23180533983767

MagdAlmuntaser

Alright, I've solved the problem, and indeed it was caused by Roundcube. I performed a downgrade of Roundcube from version 1.6.6 to 1.6.0, and the issue was resolved.

Here's how I did it:
I navigated to the following path:

/usr/local/cpanel/base/3rdparty

and renamed the Roundcube folder to roundcube_bak. Then, I pulled files from another website for Roundcube version 1.6.0 and uploaded them to the same path on my server.

SKaero

I have a installation of Roundcube 1.6.6 behind a Cloudflare proxy and it works fine. I'm guessing it is aa issue with the cPanel customizations or web server config that is causing the problem.

MagdAlmuntaser

#5
Quote from: SKaero on May 07, 2024, 12:14:27 AM
I have a installation of Roundcube 1.6.6 behind a Cloudflare proxy and it works fine. I'm guessing it is aa issue with the cPanel customizations or web server config that is causing the problem.

I have 8 dedicated servers, and all the websites hosted on them are experiencing the same issue. Two of these servers were installed just 4 days ago without any modifications to cPanel. I only installed the system, cPanel, and transferred the websites to them without NS or anything only change DNS from cloudflare, yet the same problem.

But I followed the steps I mentioned above and solved the issue on all of my servers.
It's a temporary solution until roundcube and cpanel fix this issue.

Just so you know, when the issue was present, I created a subdomain in Cloudflare for another domain and linked the IP address of the server experiencing the problem. This allowed the webmail to work for me.

Example:
The problem was with this domain, "webmail.server1.com."
I added a subdomain on the domain "test.server2.com" and linked the IP address of server1 to the subdomain "test.server2."
This made the webmail work for me.

peaceharbor

I posted this issue on Roundcubes Git as well, and someone there posted this: https://github.com/roundcube/roundcubemail/issues/9436#issuecomment-2097345467
It seems like the latest version of Roundcube is the culprit.

JohnDoh

#7
A similar comment was posted earlier in this thread. I do not use cPanel or Cloudflare. Based on posts about other cPanel powered systems I believe cPanel adds their own plugins like cpanellogin and cpanellogout for example to the Roundcube. The suggested "fix" would, I guess, remove the cPanel plugins from the application as it says Roundcube was installed from source rather than through cPanel. So my question is, have you tested a 1.6.6 install of Roundcube without the cPanel plugins?
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

MagdAlmuntaser

#8
Quote from: peaceharbor on May 07, 2024, 09:48:07 AM
I posted this issue on Roundcubes Git as well, and someone there posted this: https://github.com/roundcube/roundcubemail/issues/9436#issuecomment-2097345467
It seems like the latest version of Roundcube is the culprit.

yah it's me ..Yes, the issue is from Roundcube

Quote from: JohnDoh on May 07, 2024, 03:08:12 PM
A similar comment was posted earlier in this thread. I do not use cPanel or Cloudflare. Based on posts about other cPanel powered systems I believe cPanel adds their own plugins like cpanellogin and cpanellogout for example to the Roundcube. The suggested "fix" would, I guess, remove the cPanel plugins from the application as it says Roundcube was installed from source rather than through cPanel. So my question is, have you tested a 1.6.6 install of Roundcube without the cPanel plugins?

I took the files from another website that also uses cPanel because I know cPanel has additional files within Roundcube. That's why I pulled an older version of Roundcube from a website using cPanel.
you can download my files to try it ..
https://github.com/roundcube/roundcubemail/files/15241442/roundcube.tar.gz

MagdAlmuntaser

Quote from: peaceharbor on May 04, 2024, 11:51:03 AM
There is an issue between the Cloudflare DNS proxy....

Quote from: SKaero on May 05, 2024, 01:43:18 AM
This isn't a Roundcube issue.....

Quote from: JohnDoh on May 07, 2024, 03:08:12 PM
A similar comment was posted earlier in this thread.....

Ok guys..
Finally, I found where the problem lies. The issue is not with Roundcube, it's with the cPanel plugin, specifically CardDAV. You'll find it in this path:

/usr/local/cpanel/base/3rdparty/roundcube/plugins/carddav

The exact problem is in the config.inc.php file. An "if" condition should be added to the code to check if /var/cpanel/calendarserver exists on the server or not because it will use port 2080, which is not supported by Cloudflare.

Solution:
Replace the following code in the config.inc.php file, and the webmail will work:

$prefs['_GLOBAL']['suppress_version_warning'] = false;
$prefs['_GLOBAL']['sync_collection_workaround'] = false;
if(file_exists('/var/cpanel/calendarserver')) {
$domain = getenv('HTTP_HOST');
if( empty($domain) ) $domain = getenv('DOMAIN');
// Figure out the expected formatting based on username
$userName = (string) $_SERVER['_RCUBE'];
$userFormat = (string) '%l@%d';
if( strpos($userName, '/') === false) {
$userFormat = '%l';
}

$prefs['cPCardDAV'] = array(
   'name'     => 'cPanel CardDAV',
   'username' => $userFormat,
   'password' => '%p',
   'url'      => 'https://' . $domain . ':2080/addressbooks/' . $userFormat . '/addressbook/',
   'active'   => true,
   'fixed'    => array( 'name', 'username', 'password' ),
   'hide'     => false,
);
}

Disapper

Quote from: MagdAlmuntaser on May 10, 2024, 10:59:55 PM
Quote from: peaceharbor on May 04, 2024, 11:51:03 AM
There is an issue between the Cloudflare DNS proxy....

Quote from: SKaero on May 05, 2024, 01:43:18 AM
This isn't a Roundcube issue.....

Quote from: JohnDoh on May 07, 2024, 03:08:12 PM
A similar comment was posted earlier in this thread.....

Ok guys..
Finally, I found where the problem lies. The issue is not with Roundcube, it's with the cPanel plugin, specifically CardDAV. You'll find it in this path:

/usr/local/cpanel/base/3rdparty/roundcube/plugins/carddav

The exact problem is in the config.inc.php file. An "if" condition should be added to the code to check if /var/cpanel/calendarserver exists on the server or not because it will use port 2080, which is not supported by Cloudflare.

Solution:
Replace the following code in the config.inc.php file, and the webmail will work:

$prefs['_GLOBAL']['suppress_version_warning'] = false;
$prefs['_GLOBAL']['sync_collection_workaround'] = false;
if(file_exists('/var/cpanel/calendarserver')) {
$domain = getenv('HTTP_HOST');
if( empty($domain) ) $domain = getenv('DOMAIN');
// Figure out the expected formatting based on username
$userName = (string) $_SERVER['_RCUBE'];
$userFormat = (string) '%l@%d';
if( strpos($userName, '/') === false) {
$userFormat = '%l';
}

$prefs['cPCardDAV'] = array(
   'name'     => 'cPanel CardDAV',
   'username' => $userFormat,
   'password' => '%p',
   'url'      => 'https://' . $domain . ':2080/addressbooks/' . $userFormat . '/addressbook/',
   'active'   => true,
   'fixed'    => array( 'name', 'username', 'password' ),
   'hide'     => false,
);
}



I`ve do this but isin`t work for me.

MagdAlmuntaser

Quote from: Disapper on May 14, 2024, 07:03:19 PM
I`ve do this but isin`t work for me.

Are you sure you edited the file correctly? You can edit it using FileZilla to ensure proper editing. The file to be edited is:

/usr/local/cpanel/base/3rdparty/roundcube/plugins/carddav/config.inc.php

Or you can download the file from the attachments and replace it.

Disapper

this here is the original file


<?php
$prefs
['_GLOBAL']['suppress_version_warning'] = false;
$prefs['_GLOBAL']['sync_collection_workaround'] = false;
$domain getenv('HTTP_HOST');
if( empty(
$domain) ) $domain getenv('DOMAIN');
// Figure out the expected formatting based on username 
$userName = (string) $_SERVER['_RCUBE'];
$userFormat = (string) '%l@%d'
if( 
strpos($userName'/') === false) { 
    
$userFormat '%l'
}
 
$prefs['cPCardDAV'] = array( 
   
'name'     => 'cPanel CardDAV'
   
'username' => $userFormat
   
'password' => '%p'
   
'url'      => 'https://' $domain ':2080/addressbooks/' $userFormat '/addressbook/'
   
'active'   => true
   
'fixed'    => array( 'name''username''password' ), 
   
'hide'     => false
);

?>



this one is yours


$prefs['_GLOBAL']['suppress_version_warning'] = false;
$prefs['_GLOBAL']['sync_collection_workaround'] = false;
if(file_exists('/var/cpanel/calendarserver')) {
$domain = getenv('HTTP_HOST');
if( empty($domain) ) $domain = getenv('DOMAIN');
// Figure out the expected formatting based on username
$userName = (string) $_SERVER['_RCUBE'];
$userFormat = (string) '%l@%d';
if( strpos($userName, '/') === false) {
$userFormat = '%l';
}

$prefs['cPCardDAV'] = array(
   'name'     => 'cPanel CardDAV',
   'username' => $userFormat,
   'password' => '%p',
   'url'      => 'https://' . $domain . ':2080/addressbooks/' . $userFormat . '/addressbook/',
   'active'   => true,
   'fixed'    => array( 'name', 'username', 'password' ),
   'hide'     => false,
);
}


This is the only difference between the two

if(file_exists('/var/cpanel/calendarserver')) {


which I added to my file and it still didn't work.

MagdAlmuntaser

2024-05-23
Fixed case HB-7582: Add initial support for Outlook/Win32 timezones in cpdavd.
Fixed case HB-7589: Fix bug where postgres got uninstalled automatically as a dependency of CCS even if other things relied on it.
Fixed case RE-383: Fix debian dep for cpanel-roundcube-plugins-cpanel
Fixed case RE-331: cpanel-system-python27 on Ubuntu keeps failing on check_cpanel_pkgs
Fixed case RE-301: cPanel installs sometime end with missing packages
Fixed case HB-7504: Disabling DAV in Service Manager isn't disabling the Calendar and Contacts feature

i think cpanel fixed the problem ..