# Wrong client IP: app sees the proxy/load balancer IP instead of the visitor

**Code:** `X-Forwarded-For` · **Category:** HTTP · **Seen on:** HTTP, Nginx, Laravel, Node.js

Logs, rate limits and geo rules all show one IP (the proxy) because the real client address is in a forwarded header.

## Meaning

Behind a proxy or CDN the TCP peer is the proxy; the visitor is in `X-Forwarded-For` (or `CF-Connecting-IP`, `X-Real-IP`, PROXY protocol). Trust those headers only from your own proxies (`set_real_ip_from`, `TRUSTED_PROXIES`, `trust proxy`), otherwise users can spoof their IP.

## Common causes

- App reads the socket address only
- Real-IP module not configured
- Trusting XFF from anyone (spoofing)
- Multiple proxy hops, wrong position in the list
- CDN IP ranges not whitelisted

## Quick fix

1. Configure trusted proxies and read the forwarded header
2. nginx: `set_real_ip_from 10.0.0.0/8; real_ip_header X-Forwarded-For;`
3. Use `CF-Connecting-IP` behind Cloudflare

## Detailed fix by platform

### Nginx

1. 

```nginx
set_real_ip_from 10.0.0.0/8;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
```


## How to diagnose

1. **Peer IP** — Proxy?
2. **Trusted proxies** — Configured?
3. **Header** — Spoofable?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/http/x-forwarded-for-wrong-client-ip)
