How To: Log the Original Client IP via IIS Advanced Logging (X-Forwarded-For or X-MS-Forwarded-Client-IP)

Follow
    Applies to:
  • SecureAuth Identity Platform
Deployment model:
  • Cloud
  • Hybrid
  • On Premises
  • Version Affected: Not applicable — this is an Internet Information Services (IIS) configuration change and is not tied to a specific SecureAuth Identity Provider (IdP) version.

     

    Overview

    This article explains how to install the IIS Advanced Logging module and configure it to capture the original client IP address forwarded by a load balancer or reverse proxy — either via the standard X-Forwarded-For request header, or via X-MS-Forwarded-Client-IP, the header some Microsoft/Azure load balancers use instead. The steps are identical either way; only the header name you choose in step 6 differs.

     

    Install and Configure IIS Advanced Logging

    1. Download and install the IIS Advanced Logging module from the Microsoft Download Center. Installing the module doesn't require a reboot, but you will need to reset IIS once the new logging field below has been created.
    2. In IIS Manager, select the server or site and open the new Advanced Logging icon that the module added.

      IIS Manager showing the server's Default Web Site expanded in the Connections tree, with the IIS feature icons on the right including the new Advanced Logging icon.
       
    3. In the Actions pane, click Enable Advanced Logging.

      IIS Advanced Logging Actions pane showing an alert that the Advanced Logging feature is disabled, with an Enable Advanced Logging action link.
       
    4. Click Edit Logging Fields.

      IIS Advanced Logging Actions pane, now enabled, showing the Edit Logging Fields action link.
       
    5. Click Add Field.

      Edit Logging Fields dialog listing the built-in log fields, with the Add Field button highlighted at the bottom.
       
    6. In the Add Logging Field dialog, give the field an ID of your choice (for example, ClientSourceIP), set Source type to Request Header, and set Source name to x-forwarded-for — or x-ms-forwarded-client-ip if you're behind a Microsoft/Azure load balancer that sets that header instead.

      Add Logging Field dialog with Field ID set to ClientSourceIP, Source type set to Request Header, and Source name set to x-forwarded-for.
       
    7. Click Add Log Definition.

      IIS Advanced Logging Actions pane showing the Add Log Definition action link.
       
    8. On the Log Definition screen, add whatever other fields you want in this log, then click Select Fields and make sure the field you created in step 6 is included.

      Log Definition screen showing the Base file name set to ClientSourceIP, Enabled checked, log rollover set to Schedule/Daily, the Selected Fields list already showing ClientSourceIP, and a Select Fields button.
       
    9. In the Select Logging Fields dialog, check the field you created — the standard header and the Microsoft-specific header appear here as separate selectable fields if you've added both. Once you're done, reset IIS for the new field to start appearing in the log.

      Select Logging Fields dialog listing available fields including Microsoft (source name x-ms-forwarded-client-ip) and ClientSourceIP (source name x-forwarded-for), with ClientSourceIP checked.


     

    SecureAuth Knowledge Base Articles provide information based on specific use cases and may not apply to all appliances or configurations. Be advised that these instructions could cause harm to the environment if not followed correctly or if they do not apply to the current use case.

    Customers are responsible for their own due diligence prior to utilizing this information and agree that SecureAuth is not liable for any issues caused by misconfiguration directly or indirectly related to SecureAuth products.

    0 out of 0 found this helpful

    Comments

    0 comments

    Please sign in to leave a comment.