IIS (real visitor IP)
On IIS, Network protection can't pass the visitor's IP address for HTTPS. Those connections are sent to the origin without being decrypted, so the sentry can't add a header, and IIS has no equivalent of PROXY protocol. Website protection is the way to keep visitor IPs on IIS, so turn it on for those domains.
With Website protection on, IIS sees each connection as coming from the sentry. The sentry sends the real visitor address in the X-Real-IP header. That header is always set to the address that connected to the sentry, so a visitor can't fake it. The sentry also appends the address to X-Forwarded-For. On IIS, use X-Real-IP.
These steps apply the visitor address as REMOTE_ADDR and REMOTE_HOST, so your applications and logs see it without code changes.
1. Install the IIS URL Rewrite module
Install Microsoft's URL Rewrite module on the origin server, if it isn't already installed. On the download page, under Download URL Rewrite Module 2.1, choose the installer that matches the server (the x64 installer on a 64-bit server).
2. Allow the server variables
The rule below changes REMOTE_ADDR and REMOTE_HOST. IIS only allows that after you allow those variable names once on the server.
Open Command Prompt as Administrator and run:
%windir%\system32\inetsrv\appcmd.exe set config ^
-section:system.webServer/rewrite/allowedServerVariables ^
/+"[name='REMOTE_ADDR']" /commit:apphost
%windir%\system32\inetsrv\appcmd.exe set config ^
-section:system.webServer/rewrite/allowedServerVariables ^
/+"[name='REMOTE_HOST']" /commit:apphost
If a command says the entry already exists, that variable is already allowed; continue.
3. Add the rule to the site's web.config
In the portal, go to Clusters, open the cluster, and click each sentry's name. Public IP shows the address to use, with a Copy button. Copy the Public IP of every sentry in the cluster (IPv4, and IPv6 if they have one). Don't use Cluster interface IP if that label also appears.
Open the site's web.config and merge the block below into the existing <system.webServer> section. Don't replace the file. If the site already has rewrite rules, put this rule first in <rules>. If it doesn't, add the whole <rewrite> block.
Replace the example addresses 203.0.113.10 and 203.0.113.11 with your sentries' Public IP addresses. Escape each dot in an IPv4 address with a backslash, as in the example. With one sentry, list just that one. If a sentry has an IPv6 address, add it to the same list (colons don't need escaping). Update the rule when you add or change sentries.
<rewrite>
<rules>
<rule name="stillorigin real visitor IP" stopProcessing="false">
<match url=".*" />
<conditions>
<add input="{REMOTE_ADDR}"
pattern="^(203\.0\.113\.10|203\.0\.113\.11)$" />
<add input="{HTTP_X_REAL_IP}"
pattern="^([\d.]+|[0-9A-Fa-f:]+)$" />
</conditions>
<serverVariables>
<set name="REMOTE_ADDR" value="{HTTP_X_REAL_IP}" />
<set name="REMOTE_HOST" value="{HTTP_X_REAL_IP}" />
</serverVariables>
<action type="None" />
</rule>
</rules>
</rewrite>
The first condition applies the rule only when the connection comes from one of your sentries. The second checks that X-Real-IP looks like a single IP address. The action doesn't rewrite the URL; it only sets the two server variables.
4. Log the real IP in IIS logs (optional)
The c-ip column in IIS logs will still show the sentry, because that column is the connection address.
To record the visitor address as well, in IIS Manager open the site, go to Logging › Select Fields › Add Field, and add:
- Source type: Request Header
- Source:
X-Real-IP
Give the field a name you'll recognise, such as X-Real-IP, then apply the change.
What your applications see
After the rule is in place, applications read the visitor address from:
- Classic ASP:
Request.ServerVariables("REMOTE_ADDR") - ASP.NET:
Request.UserHostAddress - ASP.NET Core:
HttpContext.Connection.RemoteIpAddress. Some apps also use the forwarded-headers middleware; if yours does, point it atX-Real-IPand only your sentries.
IIS features that act on the connection address, including IP Address and Domain Restrictions, still see the sentry, not the visitor. Don't use those to allow or block visitors once traffic comes from your sentries. Use stillorigin's deny list, or application checks that read REMOTE_ADDR after this rule.
How to check it worked
- Confirm Website protection is on for the domain, and that HTTPS is inspected (or test over HTTP).
- Visit the site yourself, through the sentry.
- Check an application log, or a short test page that prints
Request.ServerVariables("REMOTE_ADDR")(classic ASP) orRequest.UserHostAddress(ASP.NET). It should show your address, not a sentry's Public IP. - If you added the optional log field, a new IIS log line should include your address in that field. The
c-ipcolumn will still show the sentry.
If it still shows the sentry's address, check that Website protection is on and HTTPS is inspected, that the rule is first in <rules>, that every sentry's Public IP is in the pattern, and that step 2 succeeded.