Author Topic: Cloudflare 524 Error with Roudcube  (Read 3602 times)

Offline peaceharbor

  • Newbie
  • *
  • Posts: 3
    • Peace Harbor Companies
Cloudflare 524 Error with Roudcube
« on: May 04, 2024, 11:51:03 AM »
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

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,897
    • SKaero - Custom Roundcube development
Re: Cloudflare 524 Error with Roudcube
« Reply #1 on: May 05, 2024, 01:43:18 AM »
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

Offline peaceharbor

  • Newbie
  • *
  • Posts: 3
    • Peace Harbor Companies
Re: Cloudflare 524 Error with Roudcube
« Reply #2 on: May 05, 2024, 10:43:29 PM »
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

Offline MagdAlmuntaser

  • Newbie
  • *
  • Posts: 5
Re: Cloudflare 524 Error with Roudcube
« Reply #3 on: May 06, 2024, 10:58:24 PM »
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:

Code: [Select]
/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.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,897
    • SKaero - Custom Roundcube development
Re: Cloudflare 524 Error with Roudcube
« Reply #4 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.

Offline MagdAlmuntaser

  • Newbie
  • *
  • Posts: 5
Re: Cloudflare 524 Error with Roudcube
« Reply #5 on: May 07, 2024, 02:01:46 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.
« Last Edit: May 07, 2024, 02:08:48 AM by MagdAlmuntaser »

Offline peaceharbor

  • Newbie
  • *
  • Posts: 3
    • Peace Harbor Companies
Re: Cloudflare 524 Error with Roudcube
« Reply #6 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.

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,865
Re: Cloudflare 524 Error with Roudcube
« Reply #7 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?
« Last Edit: May 07, 2024, 03:52:47 PM by JohnDoh »
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and moreā€¦

Offline MagdAlmuntaser

  • Newbie
  • *
  • Posts: 5
Re: Cloudflare 524 Error with Roudcube
« Reply #8 on: May 07, 2024, 05:36:20 PM »
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

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
« Last Edit: May 07, 2024, 05:55:40 PM by MagdAlmuntaser »

Offline MagdAlmuntaser

  • Newbie
  • *
  • Posts: 5
Re: Cloudflare 524 Error with Roudcube
« Reply #9 on: May 10, 2024, 10:59:55 PM »
There is an issue between the Cloudflare DNS proxy....

This isn't a Roundcube issue.....

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:
Code: [Select]
$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,
);
}

Offline Disapper

  • Newbie
  • *
  • Posts: 2
Re: Cloudflare 524 Error with Roudcube
« Reply #10 on: May 14, 2024, 07:03:19 PM »
There is an issue between the Cloudflare DNS proxy....

This isn't a Roundcube issue.....

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:
Code: [Select]
$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.

Offline MagdAlmuntaser

  • Newbie
  • *
  • Posts: 5
Re: Cloudflare 524 Error with Roudcube
« Reply #11 on: May 14, 2024, 09:37:13 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:

Code: [Select]
/usr/local/cpanel/base/3rdparty/roundcube/plugins/carddav/config.inc.php
Or you can download the file from the attachments and replace it.

Offline Disapper

  • Newbie
  • *
  • Posts: 2
Re: Cloudflare 524 Error with Roudcube
« Reply #12 on: May 15, 2024, 10:35:50 AM »
this here is the original file

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

?>


this one is yours

Code: [Select]
$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
Code: [Select]
if(file_exists('/var/cpanel/calendarserver')) {

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