How to set X-Real-IP, and how it differs from X-Forwarded-For
To send an X-Real-IP header from Chrome, Edge or Firefox, add a request header named X-Real-IP in HeaderDial with a single address such as 203.0.113.7, and limit it to the host you are testing. Whether the application then treats that address as the client depends on its proxy trust settings. nginx, for example, only uses the header when the request arrives from an address listed in set_real_ip_from. Checking that setting is usually the point of the test.
X-Real-IP, X-Forwarded-For and Forwarded
All three carry the client address past a reverse proxy, which would otherwise hide it. They differ in format and in who adds them:
| Header | Example | How it is used |
|---|---|---|
X-Real-IP | 203.0.113.7 | One address, normally set by the first proxy you operate (in nginx, proxy_set_header X-Real-IP $remote_addr;). It is a convention, not a standard. |
X-Forwarded-For | 203.0.113.7, 10.0.0.5 | A list. Each proxy appends the address it received the request from, so the left end is the least trustworthy. Also a convention. |
Forwarded | for=203.0.113.7;proto=https | The standard form (RFC 7239), which can also carry the protocol and host. IPv6 addresses must be quoted and bracketed: for="[2001:db8::1]". Fewer servers read it. |
Your application reads one of these, sometimes with a fallback. Find out which before testing, or send all three with the same address. For the list format and choosing test addresses, see how to set X-Forwarded-For.
Steps
- Click the HeaderDial icon. If the site-access banner appears, choose Allow on all sites or Only <current host>.
- Click + Request header, type
X-Real-IP(it is in the suggestions) and enter one address. Keep the operation on set. Browsers do not allow appending toX-Real-IP, so append is turned into set with a message saying so. - To cover the other conventions, add rows for
X-Forwarded-ForandForwarded(valuefor=203.0.113.7). - Open Where it applies, click + Only on…, choose Domain and enter the host, for example
staging.example.com. - Load a page and look at the client IP in your application log or access log.
We checked this with HeaderDial 0.2.0 in Chrome 159 and Firefox 158 in November 2026: a local test server received all three headers unchanged, on page loads and on fetch() calls.
How nginx decides whether to believe it
nginx's realip module replaces the client address ($remote_addr) with the value of a header, but only for requests whose direct peer is listed in set_real_ip_from:
# app server behind load balancers in 10.0.0.0/8
set_real_ip_from 10.0.0.0/8;
real_ip_header X-Real-IP;
# or, with X-Forwarded-For and a chain of proxies
set_real_ip_from 10.0.0.0/8;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
We ran these settings in nginx 1.31.9 (Docker image nginx:alpine, November 2026), sending headers with curl. Here 172.17.0.1 was the real peer address:
| Configuration and request | nginx used as client |
|---|---|
Peer trusted, X-Real-IP: 203.0.113.7 | 203.0.113.7 |
Peer not in set_real_ip_from, same header | 172.17.0.1 (header ignored) |
set_real_ip_from 0.0.0.0/0, same header | 203.0.113.7 (anyone is believed) |
X-Forwarded-For: 6.6.6.6, 198.51.100.9, 10.0.0.5, real_ip_recursive on | 198.51.100.9 |
Same, real_ip_recursive off (the default) | 10.0.0.5 |
real_ip_header Forwarded, Forwarded: for=203.0.113.7;proto=https | 172.17.0.1 (the for= syntax is not parsed) |
With real_ip_recursive on, nginx reads the list from the right and skips trusted addresses, so the forged 6.6.6.6 on the left is never used. With it off, nginx takes the last address, which is often your own proxy. And 0.0.0.0/0 trusts everyone, so any client can set its own IP.
The proxy in front matters as much. We also put one nginx in front of another that trusted only it. When the front proxy had proxy_set_header X-Real-IP $remote_addr;, the client's forged value was overwritten and the application saw the real address. Without that line, the forged 203.0.113.7 passed straight through and was believed.
Check that production ignores forged values
- Load a page on production without any rule and note the client IP your logs record. That is your real address.
- Make a profile named "Forged IP" with
X-Real-IP,X-Forwarded-ForandForwardedall set to203.0.113.7, limited to the production host. - Reload and check the same log, plus anything keyed on IP: rate limits, geo decisions, audit entries, allow-lists.
- If
203.0.113.7appears anywhere, some layer trusts client-supplied headers. Look for aset_real_ip_fromthat is too wide, a front proxy that passes the header through instead of overwriting it, or a framework's "trusted proxies" setting that trusts every address.
The curl equivalent
curl -H "X-Real-IP: 203.0.113.7" https://staging.example.com/whoami
curl -H "X-Real-IP: 203.0.113.7" \
-H "X-Forwarded-For: 203.0.113.7" \
-H "Forwarded: for=203.0.113.7" https://www.example.com/
Pitfalls
- CDNs add their own headers. Behind a CDN, the application may read a CDN-specific header (Cloudflare's is
CF-Connecting-IP), and the CDN may overwriteX-Forwarded-For. Your value may never reach the application. - Documentation addresses have no country.
203.0.113.0/24is fine for testing trust and logging, but geolocation needs a real address from the region. - Switch it off afterwards. Give the rows an expiry such as 1 hour, or press Alt+Shift+D to pause every profile.
Add to ChromeFirefox: coming soon