← Back

Apps behind Cloudflare or a load balancer now receive the visitor's IP

Improvement

Caddy now hands your app the visitor's IP address as the only value in X-Forwarded-For, instead of the full proxy chain, so apps behind Cloudflare or an external load balancer get the real visitor in request.remote_ip, sessions, rate limiting and logs without any trusted proxy configuration of their own. Caddy also drops the client-supplied Forwarded and Client-IP headers, which vulnerability scanners were using to trigger IpSpoofAttackError 500s in Rails apps.

One thing to check: if your app inspected the last entry of X-Forwarded-For to confirm a request arrived through Cloudflare, that entry is no longer there. Two stronger options are a firewall at your provider that only allows ports 80 and 443 from Cloudflare's IP ranges, or a Cloudflare Transform Rule that adds a secret request header your app checks. Reach out to support if you'd like help setting either one up.

A small number of servers on Caddy builds older than 2.8 keep the previous X-Forwarded-For chain until Caddy is upgraded there.