By default, NSX Advanced Load Balancer Service Engines (SEs) source-NAT (SNAT) traffic is destined to servers. Due to SNAT, logs on the application servers will show the layer 4 IP address of the SE rather than the original client’s IP address. Most application servers can leverage the XFF header as the source IP address for logging or blocklisting.

For HTTP traffic, NSX Advanced Load Balancer can be configured to insert an X-Forwarded-For (XFF) header in client-server requests to include the original client IP addresses in the logging requests. This feature is supported for IPv6 in NSX Advanced Load Balancer.

To include the client’s original IP address in HTTP traffic logs, enable NSX Advanced Load Balancer to insert an XFF header into the client traffic destined for the server. XFF insertion can be enabled in the HTTP application profile attached to the virtual service.

  1. Navigate to Templates > Profiles > Application.

  2. Click on the edit icon near a HTTP Application Profile to open the following editor:

  3. Within the General tab, select the X-Forwarded-For check box.


    Optionally the header can be renamed using the XFF Alternate Name field.

  4. Click Save.

The profile change affects any virtual services that use the same HTTP application profile.

When XFF header insertion is enabled, the SE checks the headers of client-server packets for existing XFF headers. If XFF headers already exist, the SE first removes any pre-existing XFFs, then inserts its own XFF header. This is done to prevent clients from spoofing their IP addresses.

Keeping Pre-existing XFF Headers

There are times when this behavior (removing pre-existing XFF headers) is not desired, such as when multiple proxies may be SNATing and inserting XFF headers. In this case, to insert an XFF header without removing pre-existing XFF headers, use either a DataScript or an HTTP Request Policy.


avi.http.add_header("XFF", avi.vs.client_ip())