I just deployed a fresh VM image of my test server to make sure I hadn't done anything to the IIS config to screw this up. This is on a fresh 2008 x64 image with SP2 applied.
Here is my web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="test">
<match url="(.*)" />
<serverVariables>
<set name="REMOTE_ADDR" value="::2" replace="true"/>
<set name="HTTP_FOO" value="Hello" replace="true"/>
</serverVariables>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
And here is the ASP:
<html>
<head>
<title>boo</title>
</head>
<body>
<p>REMOTE_ADDR is <%= request.servervariables("REMOTE_ADDR") %></p>
<p>Foo is <%= request.servervariables("HTTP_FOO") %></p>
</body>
And here is my output the first time I hit the page (the IP returned is that of our load balancer):
REMOTE_ADDR is x.x.x.x
Foo is Hello
What is weird is that if I refresh the page the "Hello" drops off, until I recycle the app pool. If I define the rule in the applicationHost.config instead of web.config I get the same result as far as the IP address but the "Hello" does not drop off after one request.
I don't see any errors in the application or system logs when I have the rule defined in web.config, but I did get a sxs error when I installed URL Rewrite:
Activation context generation failed for "C:\Windows\system32\inetsrv\rewrite.dll". Dependent Assembly Microsoft.VC90.CRT,processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.30729.1" could not be found. Please use sxstrace.exe for detailed diagnosis.
I checked and that assembly is in my c:\windows\winsxs folder.