0

I'm running a website on Apache2/Ubuntu 20.04, and for some reason I'm getting a really long TTFB (~15 seconds), this only happens while I'm using Cloudflare's Proxy/CDN. If I'm connecting directly to my server's IP address (without Cloudflare's Proxy/CDN) (inside & outside of my network), this long TTFB doesn't happen.

Network analysis screenshot

In the image link above, you can see that Cloudflare returns a status "522", which means that the connection timed out, and Cloudflare could not negotiate a TCP handshake with the origin server. But the website actually loads after these 15 seconds.

On the same system that I'm running Apache, I'm running a html control panel called "Webmin" (not hosted in Apache), to manage my server remotely, and I'm using it with Cloudflare's Proxy as well, and the same thing happens with it, I get the same ~15 seconds for the TTFB. I think is worth noting as well that I have another server on the same network that is running Windows 10 with IIS as the hosting server, and I'm using Cloudflare's Proxy/CDN, and I've never had any problems with it. With that, I think this might be some problem with Ubuntu, but I have no clue of what could it be.

Here's what I've done already, but even after doing all of those things I'm still getting that long TTFB:

  • Specified the Cipher Suite in Apache's configuration file.
  • I've added all of Cloudflare's chained certificates (including Cloudflare's Root CA).
  • Whitelisted all of Cloudflare's IP ranges in Ubuntu's firewall.
  • Specified TLS/SSL version in Apache's configuration file.
  • Checked and reinstalled Cloudflare origin CA.

The Apache configuration file & other archives that might be useful are available here.

Any help is much appreciated!

[UPDATE] After many days trying to get it working, I've figured out that the problem was the port that I was using (8443), which is supported by Cloudflare on every plan, and for some reason I'm getting this long TTFB. By the way, that's not a problem with my network or ISP, because when I run it on plain HTTP (without Cloudflare's Proxy/CDN) with the same port (8443), I get a "normal" TTFB.

0

As you said with cloudfare enabled, (TTFB) is high.

Any firewall rules on the machine (Ubuntu) might delay the incoming request via cloudfare to the destination server.

Try disabling the firewall & check whether it lowers the (TTFB).

| | |
  • Hi, I've disabled the firewall, and purged the cache on Cloudflare, but I'm still getting the same results. But thanks for the help anyways – ALEX BREED Jul 3 at 17:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.