So you have a new F5 NLB, You have a new site hosted on IIS behind said F5…And now you have broken IIS Logging…
You may find that after deploying F5, any IIS logging will now reflect the internal IP of the F5 unit, and not the external address of the actual client. Why? When requests are passed through proxies/load balancers, the client no longer has a direct connection to the web-server itself, all traffic is proxied by the F5-Unit and the traffic looks like its coming from the last hop in the chain (F5)
So how do we get our logging back? Easy, it just requires two simple pre-requisites (and no downtime).
First is to insert an “X-Forwarded-For” header into each request to the web server. This header is a non-standardised header used for identifying the originating IP address of a client connecting to a web server via an HTTP proxy or load balancer.
To Insert X-Forwarded header:
- From your F5 Web console select Local Traffic > Select Profiles > Select Services
- Choose One of your custom HTTP profiles or select the default HTTP profile to edit all child profiles
- Scroll down the page and locate the “Insert X-Forwarded-For” property and enable it (you may need to select the custom check-box first depending on your profile type)
- Select update to apply changes
Next step is to install an ISAPI filter developed by F5 to amend IIS’s logging with the correct requester IP using the X-Forwarded for HTTP header Syntax {X-Forwarded-For: clientIP, Proxy1IP, Proxy2IP} (this filter is supported on both IIS6 & 7)
Download the ISAPI filter here: https://devcentral.f5.com/downloads/codeshare/F5XForwardedFor.zip
- Copy the F5XForwardedFor.dll file from the x86\Release or x64\Release directory (depending on your platform) into a target directory on your system. Let’s say C:\ISAPIFilters.
- Ensure that the containing directory and the F5XForwardedFor.dll file have read permissions by the IIS process. It’s easiest to just give full read access to everyone.
- Open the IIS Admin utility and navigate to the web server you would like to apply it to.
- For IIS6, Right click on your web server and select Properties. Then select the “ISAPI Filters” tab. From there click the “Add” button and enter “F5XForwardedFor” for the Name and the path to the file “c:\ISAPIFilters\F5XForwardedFor.dll” to the Executable field and click OK enough times to exit the property dialogs. At this point the filter should be working for you. You can go back into the property dialog to determine whether the filter is active or an error occurred.
- For II7, you’ll want to select your website and then double click on the “ISAPI Filters” icon that shows up in the Features View. In the Actions Pane on the right select the “Add” link and enter “F5XForwardedFor” for the name and “C:\ISAPIFilters\F5XForwardedFor.dll” for the Executable. Click OK and you are set to go.
If you’re that way inclined – there is also an IIS Module available if you think ISAPI filters are not for you (See: https://devcentral.f5.com/weblogs/Joe/archive/2009/12/23/x-forwarded-for-http-module-for-iis7-source-included.aspx)
Let me know if you have any questions 🙂
-Patrick