Using Cloudflare with BlitzPress
Cloudflare Integration Guide
Cloudflare is a popular CDN and security layer. It works well with BlitzPress but requires correct configuration to avoid conflicts with OLS caching and SSL.
SSL Mode: Full (Strict)
This is the most important setting. In Cloudflare dashboard, go to SSL/TLS and set the mode to Full (Strict).
- Flexible — causes redirect loops (Cloudflare connects to your server via HTTP)
- Full — works but does not validate your origin certificate
- Full (Strict) — correct setting; validates the Let’s Encrypt cert on your BlitzPress server
Proxy Mode (Orange Cloud)
When the orange cloud is enabled, traffic routes through Cloudflare’s network. This provides DDoS protection and CDN caching. However:
- Your real server IP is hidden (good for security)
- Cloudflare caches static assets (CSS, JS, images) — this may conflict with LSCache
- SSL issuance via HTTP challenge may fail — see the SSL Troubleshooting article
Recommended Page Rules
| URL Pattern | Setting | Purpose |
|---|---|---|
| example.com/wp-admin/* | Cache Level: Bypass | Never cache admin area |
| example.com/wp-login.php | Cache Level: Bypass | Never cache login page |
| example.com/* | Browser Cache TTL: 4 hours | Reasonable default |
Cache Purge Integration
When using both LSCache and Cloudflare, you need to purge both caches when content changes. The LiteSpeed Cache plugin can integrate with Cloudflare’s purge API:
- In WordPress, go to LiteSpeed Cache > CDN
- Enable Cloudflare API
- Enter your Cloudflare API token and zone ID
- Enable “Purge Cloudflare cache when purging LSCache”
Development Mode
When making changes to your site, enable Development Mode in Cloudflare to bypass the cache for 3 hours. This lets you see changes immediately without purging.
Under Attack Mode
If your site is being attacked, enable Under Attack Mode. This shows a JavaScript challenge to visitors before they reach your site. Use sparingly — it adds a 5-second delay for all visitors.
Restoring Real Visitor IPs
Since traffic comes through Cloudflare, your logs will show Cloudflare IPs. OLS can restore real IPs via the X-Forwarded-For header. BlitzPress configures this automatically.