Logging the real client IP in IIS behind Imperva

When IIS sits behind Imperva Cloud WAF (formerly Incapsula), your logs show Imperva addresses instead of your visitors. Here is which headers carry the client address, what Imperva's public documentation leaves open, and how to record the real client IP in the standard IIS log.

Short answer. Imperva's Customer Setup Checklist says that by default Imperva inserts the original client IP into two request headers, X-Forwarded-For and Incap-Client-IP. IIS reads neither, and its c-ip field is filled from the TCP connection, so it records an Imperva address. Log the header as a column to see the visitor, as below, or use something that validates the header against Imperva's published ranges to put the visitor into c-ip itself.

To see the visitor in your log today, add the header as a custom column (elevated PowerShell):

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' `
  -filter "system.applicationHost/sites/siteDefaults/logFile/customFields" `
  -name "." `
  -value @{logFieldName='Incap-Client-IP';sourceName='Incap-Client-IP';sourceType='RequestHeader'}

It adds a cs(Incap-Client-IP) column and does not change c-ip. Only need the column? The free custom log field covers that, and the section below says where it stops being enough.

What Imperva sends, and what it does not say

HeaderDefaultWhat the documentation says
X-Forwarded-ForOnInserted with the client IP, per the Customer Setup Checklist. Imperva's public pages do not say whether an inbound value is appended to or replaced.
Incap-Client-IPOnInserted with the client IP, per the same checklist. Its format is not described in the pages we could read. A reply in Imperva's community forums says the name can be changed in the site's Delivery advanced settings; we could not find this in current documentation, so check the name that actually arrives.

Rather than guess at the open points, test them. Add both headers as custom log fields, send one request through the Imperva hostname with a made-up X-Forwarded-For: 203.0.113.9 header of your own, and read the log. You will see whether Imperva appended to your value, replaced it or passed it through, and what the other header looks like.

Lock the origin to Imperva

Every header-based approach assumes requests reached IIS through Imperva. Imperva's article on allowlisting its IP addresses says there should be no reason to accept traffic from any source other than Imperva, and lists the ranges to allow. It also publishes them through an API at my.imperva.com/api/integration/v1/ips, with response formats for Apache, Nginx, iptables, JSON and plain text. IIS is not among the listed formats, so build the allowlist from the JSON or text output.

The list changes. Imperva's May 2023 release notes announced a new range, 131.125.128.0/17, and warned that origins that did not allowlist it could see a site outage, so refresh your firewall rules and the Proxy Trust List from the current list rather than copying addresses from a page like this one.

The fix: X-Forwarded-For for IIS

Winfrasoft X-Forwarded-For for IIS is an ISAPI web filter that reads the header Imperva sends and writes the real client address into the standard IIS c-ip log field. Same log file, same W3C schema, same column your collector already parses. No application changes and no second log file.

Step by step

  1. Log both headers as custom fields for a day (above) and confirm which one arrives and what it contains.
  2. Install the filter on the IIS servers behind Imperva and set the header name to match.
  3. Populate the Proxy Trust List with Imperva's current ranges, plus every internal hop between Imperva and IIS such as a load balancer. The filter reads the chain from the right, skips the hops you trust, and logs the first address that is not one of yours.
  4. Close the origin to everything except Imperva at the firewall.
  5. Make a request through the Imperva hostname and confirm c-ip now holds the client address.

Is the free custom log field enough?

If all you need is the address somewhere in the log, IIS 8.5 and later can record the header as an extra column with no product, using the snippet at the top of this page. That appends a cs(Incap-Client-IP) column to the W3C log. It does not change c-ip.

It stops being enough when:

The click-through steps, and the log-file naming caveat, are in how to log X-Forwarded-For in IIS. If any of the points above applies, X-Forwarded-For for IIS 10 is the supported way to put the validated client address into c-ip itself.

Frequently asked questions

Which header does Imperva send for the client IP?

Per Imperva's Customer Setup Checklist, X-Forwarded-For and Incap-Client-IP, both inserted by default. Neither changes the IIS c-ip field, which records the TCP peer, so IIS logs an Imperva address until something reads the header.

Does Imperva append to X-Forwarded-For or replace it?

Imperva's public documentation does not say, so do not assume either. Send a request through Imperva with an X-Forwarded-For value of your own, log the header as a custom field, and read what arrives. If your value survives at the left of the chain, a forged entry can reach your origin.

Where do I get Imperva's IP ranges for the Proxy Trust List?

From Imperva's article on allowlisting its IP addresses, or from the my.imperva.com/api/integration/v1/ips API, which returns JSON or plain text, among other formats (IIS is not one of them). Imperva says the list changes periodically, so refresh it rather than hard-coding it.

Can I log Incap-Client-IP instead of X-Forwarded-For?

Yes, as a custom log field on IIS 8.5 and later, and it costs nothing. It gives you an extra column and leaves c-ip unchanged. Imperva's pages we could read do not describe its format, and like any header it can be forged by someone who reaches your origin directly, so lock the origin down either way.

Get X-Forwarded-For for IIS

Log the real client IP in the standard IIS c-ip field behind Imperva, with a Proxy Trust List so the value is validated rather than merely copied. IIS 10 on Windows Server 2016–2025, with a free 14-day trial.

View the product   or request a download →

Stuck on your setup? Email us with your proxy and what c-ip shows, and we will take a look.