Putting Cloudflare in front of a site is one of the most useful free things you can do: it hides the server's real IP, caches pages and stops a large share of bots. But once you switch on the orange cloud, the site starts to behave a little differently. Below are five problems we ran into on our own site and forum, with the exact cause and how we fixed each one.
1. "[email protected]" instead of an email address
Symptom: instead ofsupport@example.com readers see the text [email protected], and clicking it gives a 404 at /cdn-cgi/l/email-protection. On our forum this did not only hit email addresses. The command ssh user@ssh.example.com also turned into "[email protected]" because it looks like an email.Cause: Cloudflare has a feature called Email Address Obfuscation (Scrape Shield) that is on by default. It hides anything that looks like an email from bots and shows it again with JavaScript. If the JavaScript does not run (RSS, readers, some apps, copying code) or the text is inside
<code>, the visitor sees "[email protected]".Fix: there are two ways:
- Turn the feature off for the whole domain: Cloudflare → your domain → Scrape Shield → Email Address Obfuscation → Off.
- Turn it off only for part of the page: wrap the content in HTML with
<!--email_off-->...<!--/email_off-->. That is what we did on the forum. We put the markers in the phpBB style around the whole content, and all 334 pages show emails and commands correctly again.
2. Error 520 only on the http:// address
Symptom:https://forum... works, but http://forum... (without the "s") returns Error 520: Web server is returning an unknown error. We noticed because Ahrefs suddenly showed a site health of 0 out of 100 and only 2 crawled pages.Cause: 520 means Cloudflare reached your server but got an empty or unreadable answer. Our subdomain had an nginx
server block only for port 443. Requests on port 80 fell into the first port-80 block, which was a catch-all with return 444;. In nginx, code 444 closes the connection without sending anything, and Cloudflare shows 520.Fix: every subdomain also needs its own port-80 block that redirects to https:
Code: Select all
server {
listen 80;
server_name forum.example.com;
return 301 https://$host$request_uri;
}Check:
Code: Select all
curl -sI http://forum.example.com/ | head -3301 and Location: https://..., not 520.3. You changed something, but everyone still sees the old version
Symptom: you change the CSS or some text and everything is fine on the server, but the browser (and Google) still show the old version. Ctrl+F5 does not help, because the old file comes from Cloudflare's cache, not from the browser.Cause: Cloudflare caches static files (CSS, JS, images). Our CSS had
max-age=14400, which is 4 hours. If you also have a Cache Rule for HTML pages (we cache HTML for 2 hours so pages load fast from far away), the pages themselves stay old too.Fix:
- For CSS and JS, change the version in the URL on every edit:
style.css?v=7→style.css?v=8. To Cloudflare this is a new file, and it fetches it right away. - For HTML: Cloudflare → Caching → Configuration → Purge Cache (it can purge only specific URLs). We run it from a script through the API after every site change.
cf-cache-status header shows what Cloudflare returned:
Code: Select all
curl -sI https://www.example.com/style.css | grep -iE 'cf-cache-status|cache-control|age'HIT means it came from the cache, and MISS or EXPIRED means it was fetched fresh from the server.4. Every visitor in the logs comes from Cloudflare
Symptom: in the nginx access.log every IP is from Cloudflare's networks (104.16.x.x, 172.64.x.x ...). Fail2ban bans Cloudflare instead of the attacker, and per-country statistics are useless.Cause: the visitor connects to Cloudflare, and Cloudflare connects to your server. The real IP arrives in the
CF-Connecting-IP header.Fix: tell nginx to trust that header, but only when the request comes from Cloudflare's networks. We have it in
/etc/nginx/conf.d/cloudflare-real-ip.conf:Code: Select all
# Cloudflare IPv4 and IPv6 ranges: https://www.cloudflare.com/ips/
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 104.16.0.0/13;
# ... the rest of the list ...
real_ip_header CF-Connecting-IP;
real_ip_recursive on;sudo nginx -t && sudo systemctl reload nginx, and the logs show the real addresses.Important: do not use
set_real_ip_from 0.0.0.0/0. Then anyone can send a fake header and appear with any IP they like. Cloudflare's list changes rarely, but check it from time to time.5. Cloudflare Web Analytics shows 0 visitors
Symptom: Web Analytics has been on for months, and the chart is empty.Cause: in our case it was two things at once:
- The setting was "Enable, excluding visitors from the EU". For a site in Bulgaria that means almost no data.
- The site has a strict Content-Security-Policy, and it blocked Cloudflare's script. The browser simply refused to load it.
Code: Select all
script-src ... https://static.cloudflareinsights.com;
connect-src ... https://cloudflareinsights.com;curl you will not see it, so add an Accept header:Code: Select all
curl -s -H 'Accept: text/html' https://www.example.com/ | grep -o 'cloudflareinsights[^"]*' | head -1In short
- "[email protected]" → Email Obfuscation Off or
<!--email_off-->. - 520 on http:// → a port-80 block with a 301 to https.
- The old version after a change →
?v=for CSS/JS and Purge Cache for HTML. - Cloudflare IPs in the logs →
real_ip_header CF-Connecting-IP, only for Cloudflare's networks. - 0 in Web Analytics → no "excluding EU", and the script allowed in the CSP.