Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the X-Forwarded-For header on IIS reverse proxy setup?

When using IIS as a reverse proxy I want to pass through the IP address of the remote user to my backend web server. This must be done using the X-Forwarded-For header.I want only keep remote user IP in X-Forwarded-For header, which clears out any other proxy server IP.

So I using Url rewrite proxy to test if the X-Forwarded-For could be modified. this is my settings:

<rule name="replace X forward for">
    <match url=".*" />
    <serverVariables>
        <set name="HTTP_X_FORWARDED_FOR" value="100.100.100.100" />
    </serverVariables>
    <action type="None" />
</rule>

before my testing X-FORWARDED-FOR:10.87.50.47.51579

after my test: X-FORWARDED-FOR:100.100.100.100,10.87.50.47.51579

Why can't replace the original value? Or is there any other way to modify X-Forwarded-For header?

Any help I would appricaite! Thanks

like image 351
JohnnyLiao Avatar asked Nov 21 '13 05:11

JohnnyLiao


People also ask

How do I enable X-Forwarded-For header in IIS?

In the main menu of the LoadMaster WUI, select Virtual Services > View/Modify Services. Click Modify on the relevant Virtual Service. Expand the Advanced Properties section. In the Add HTTP Headers drop-down list, select either X-Forwarded-For (No Via) or X-Forwarded-For (+ Via).


1 Answers

I found the answer.In Application Request Routing Cache-->Server Proxy Settings-->Preserve client IP in the following header--> leave it blank.

http://technet.microsoft.com/en-us/library/dd443533(v=ws.10).aspx

Preserve client IP in the following header:

Indicates whether the header should keep the client IP address for the specified header value. The default value is X-Forwarded-For. If you leave this field blank, then no client IP address will be passed through as a custom header to the application server.

like image 174
JohnnyLiao Avatar answered Sep 24 '22 18:09

JohnnyLiao