Real client IP in IIS: guides & knowledge base.
Practical, vendor-specific guides for logging the real client IP address in Microsoft IIS behind proxies, load balancers and CDNs, using the X-Forwarded-For header.
Short answer. If IIS sits behind a proxy, load balancer or CDN, the c-ip field in your logs records that device, not your visitor, because c-ip is filled from the TCP connection and the only connection IIS sees is the one from the proxy. The visitor's address does arrive, in the X-Forwarded-For request header, but IIS has never read that header natively. Closing the gap means getting the header value into the c-ip field, and trusting only the proxy that set it. The guides below cover that for each vendor, and X-Forwarded-For and IIS covers the header itself if you want the background first.
Which guide do I need?
Start from whatever sits in front of IIS. The mechanism is the same everywhere, but the header name and the addresses you have to trust are not.
| In front of IIS | Header carrying the client IP | Guide |
|---|---|---|
| Cloudflare | CF-Connecting-IP, and X-Forwarded-For | IIS behind Cloudflare |
| F5 BIG-IP | X-Forwarded-For (once the HTTP profile inserts it) | IIS behind F5 BIG-IP |
| AWS ALB, ELB or CloudFront | X-Forwarded-For | IIS behind an AWS load balancer |
| Azure App Gateway or Front Door | X-Forwarded-For, plus X-Azure-ClientIP and X-Azure-SocketIP | IIS behind Azure |
| Nginx or HAProxy | X-Forwarded-For (you configure it) | IIS behind Nginx or HAProxy |
| IIS ARR | X-Forwarded-For, plus X-ARR-LOG-ID | IIS behind ARR |
| Barracuda WAF or Load Balancer ADC | X-Forwarded-For (inserted by default in proxy mode) | IIS behind Barracuda |
| Akamai | X-Forwarded-For, plus True-Client-IP if enabled | IIS behind Akamai |
| Fortinet FortiWeb | X-Forwarded-For (off until you enable it) | IIS behind FortiWeb |
| Citrix NetScaler (ADC) | X-Forwarded-For (if you enable Client IP header) | IIS behind Citrix NetScaler |
| Google Cloud Application Load Balancer | X-Forwarded-For (client is second from the right) | IIS behind a Google Cloud load balancer |
| Fastly | X-Forwarded-For, and Fastly-Client-IP | IIS behind Fastly |
| Imperva Cloud WAF (Incapsula) | X-Forwarded-For and Incap-Client-IP | IIS behind Imperva |
| Something else, or you are not sure | Compare them side by side | Proxy client IP header reference |
Running a specific application rather than a plain site? See Exchange behind a load balancer, SharePoint behind a reverse proxy, or ASP.NET Core UseForwardedHeaders. Replacing the retired F5 component is covered in replacing the F5 ISAPI filter on IIS 10, and if this is a logging and audit requirement rather than an analytics one, start with IIS client IP for SIEM and compliance. Already added a custom log field and found it empty? See IIS custom field for X-Forwarded-For not working.
Why the leftmost address in X-Forwarded-For is the wrong one
The header is a comma-separated chain, and each proxy appends the address it received the connection from. That makes the leftmost entry the one furthest from you, and the one entirely under the caller's control: anyone can send an X-Forwarded-For header containing any address they like before your proxy ever sees the request. The reliable value is found by reading the chain from the right and stopping at the first address that is not a proxy you trust. That is what a Proxy Trust List is for, and it is why "just log the header" is not a safe answer on its own. The header reference works through the ordering in detail, and how to log X-Forwarded-For in IIS covers what the native IIS custom log field does and does not solve.
All guides
No guides match that search. Try a different term, or get in touch. X-Forwarded-For for IIS works behind any proxy, load balancer or CDN, whether or not there's a guide for it yet.
X-Forwarded-For and IIS
Start hereWhat the header contains and why the leftmost address is the wrong one, whether IIS supports it natively (it does not, in any version), what the IIS 8.5 custom log field does and does not solve, and which of the three things people mean by this question you are actually asking.
Read the guide →Which client IP header does your proxy send?
ReferenceA table of the client IP headers set by Cloudflare, AWS, Azure, F5, ARR, Nginx, HAProxy, Akamai and Fastly, which are on by default, how the X-Forwarded-For chain is ordered, and why the leftmost address isn't the one to trust.
Read the reference →How to log X-Forwarded-For in IIS
ReferenceAdding an X-Forwarded-For column on IIS 8.5 and later, server-wide with PowerShell, and why the Advanced Logging route for IIS 7 to 8 is now closed. Then why that column leaves c-ip still showing your proxy, and what to do about it.
Read the reference →IIS custom field for X-Forwarded-For not working
TroubleshootingYou added the field and the column is missing, empty or all dashes. The nine causes, starting with the one nobody expects: IIS quietly starts writing a second log file with _x on the end, and your data is in that one. Plus why Add Field is greyed out, and the Source Type that silently matches nothing.
Frequently asked questions
FAQThe questions we're asked most often: the c-ip field versus a custom log column, replacing the old F5 ISAPI filter on IIS 10, and Exchange behind a load balancer.
Read the FAQ →Replacing the F5 X-Forwarded-For ISAPI filter on IIS 10
MigrationF5 archived its DevCentral ISAPI filter and F5XFFHttpModule HTTP module in 2016. Which component you have, what Microsoft says about IIS 10, why neither validates the forwarding chain, and how to migrate without changing anything downstream.
Read the guide →IIS client IP for SIEM and compliance
GuideWhy SIEM connectors, geo-IP lookups and compliance parsers all key off the standard c-ip field, why an extra log column doesn't satisfy them, and why an unvalidated header weakens an audit trail.
Read the guide →Exchange behind a load balancer: the real client IP
GuideOn-premises Exchange published through an F5, NetScaler or Azure Application Gateway logs the balancer's address for OWA and ActiveSync. Fixing the IIS audit trail, and the free native fix for IP Address and Domain Restrictions.
Read the guide →SharePoint behind a reverse proxy: the real client IP
GuideMulti-WFE SharePoint farms published through a load balancer log the proxy's address, not the visitor. Getting the real client IP into the IIS c-ip field farm-wide, and what this does and doesn't cover.
Read the guide →Logging the real client IP in IIS behind Nginx or HAProxy
GuideNeither proxy forwards the client IP unless you configure it to. The one directive each needs: proxy_set_header in Nginx, option forwardfor in HAProxy, and how to get the address into your IIS logs once it arrives.
Read the guide →ASP.NET Core UseForwardedHeaders behind a proxy
GuideConfiguring ForwardedHeadersOptions properly: middleware order, KnownProxies, ForwardLimit, why it silently does nothing in production, and where it stops short of fixing the IIS log itself.
Read the guide →Logging the real client IP in IIS behind Cloudflare
GuideBehind Cloudflare, IIS logs the edge IP rather than the visitor. How to restore the real client IP in your IIS logs from the X-Forwarded-For header, with a Proxy Trust List and origin lock-down.
Read the guide →Logging the real client IP in IIS behind F5 BIG-IP
GuideBehind an F5 BIG-IP, IIS logs the SNAT address. Enable Insert X-Forwarded-For on the HTTP profile and record the real client IP in your IIS c-ip field.
Read the guide →Logging the real client IP in IIS behind Barracuda
GuideThe Barracuda WAF and Load Balancer ADC send X-Forwarded-For by default in proxy mode. Why Client Impersonation is not free, and why the IIS procedure in Barracuda's own documentation cannot be followed on IIS 10.
Read the guide →Logging the real client IP in IIS behind Akamai
Vendor guideAkamai sends X-Forwarded-For by default and True-Client-IP only when somebody enables it. Why the single-value header looks more trustworthy than it is, the toggle that lets clients set it themselves, and which addresses belong in the trust list when you run Site Shield.
Logging the real client IP in IIS behind FortiWeb
Vendor guideFortiWeb hides the client from IIS unless Add X-Forwarded-For is on (off by default). The modes, the Client Real IP option, and where Fortinet's own documentation disagrees with itself.
Read the guide →Logging the real client IP in IIS behind Citrix NetScaler
Vendor guideNetScaler connects from its own SNIP by default. The Client IP header, USIP and a rewrite policy compared, with the CLI, what each does to c-ip, and what Citrix's documentation does not settle.
Logging the real client IP in IIS behind a Google Cloud load balancer
Vendor guideGoogle Cloud's Application Load Balancer appends the client IP and its own address to X-Forwarded-For, so the client is second from the right. Which entry to trust, the source ranges, and why a passthrough Network Load Balancer needs no fix.
Logging the real client IP in IIS behind Fastly
Vendor guideFastly appends to X-Forwarded-For and documents a Fastly-Client-IP header that is not protected at the edge. Why the leftmost entry is not safe, what shielding changes, and how Fastly's public IP list relates to the trust list.
Logging the real client IP in IIS behind Imperva
Vendor guideImperva Cloud WAF inserts the client IP into X-Forwarded-For and Incap-Client-IP by default. What Imperva's public documentation does and does not say about them, how to test the open points yourself, and what belongs in the trust list.
Barracuda and IIS 10: the Advanced Logging route is gone
GuideBarracuda's IIS instructions begin with a Microsoft extension that no longer exists. What happens at each dead link, how to set up Enhanced Logging properly instead, and the four things it still does not fix.
Read the guide →Logging the real client IP in IIS behind an AWS load balancer
GuideBehind an AWS ALB or Classic ELB, IIS logs the load balancer's private IP. Use the automatically-added X-Forwarded-For header to log the real visitor in IIS.
Read the guide →Logging the real client IP in IIS behind Azure App Gateway / Front Door
GuideBehind Azure Application Gateway or Front Door, IIS logs the Azure service IP. Log the real client IP from X-Forwarded-For and trust the right Azure addresses.
Read the guide →Logging the real client IP on IIS behind ARR
GuideWith Application Request Routing as a reverse proxy, backend IIS logs the ARR server IP. Preserve the client IP via X-Forwarded-For and log it on the backend.
Read the guide →Need a setup we haven't covered? X-Forwarded-For for IIS works behind any proxy, load balancer or CDN that sets the X-Forwarded-For header. Get in touch and we'll help with your specific deployment.