When attempting to route traffic through an VMware NSX Native Load Balancer (LB) to a backend server that expects a different endpoint than the client-requested URL, users may experience the following:
VMware NSX
Modern backend services (such as those hosted on Kubernetes or specific application frameworks) often require a specific Host header and URI path to properly route requests. If the client sends a request to a legacy or different URL, the NSX Load Balancer must be configured to perform a double rewrite (Host and Path) before forwarding the request to the server pool.
To resolve this, configure Request Rewrite Phase rules on the Layer 7 Virtual Server to modify the incoming request headers and URI before the request is forwarded to the backend pool.
Below are typical examples of URI and header rewrites and redirects which can be used to accomplish the traffic redirection, some or all of these may or additional rules may be required, based on the requirements of the backend pool.
Match Conditions:
Condition: HTTP Request URI
Match: Equals
URI: </incoming/original/path/>
Case Sensitive: Off
Negate: Off
Match Strategy: ALL
Actions:
Action: HTTP Request URI Rewrite
URI: </new/backend/path/>
Condition: HTTP Request Header
Header Name: <Incoming Header Name>
Match Type: Equals
Header Value: <Incoming Header Name Value>
Case Sensitive: Off
Negate: Off
Match Strategy: ALL
Actions
Action: Select Pool
Select Pool: <Pool to send traffic to that matches the header>
Condition: HTTP Request Header
Header Name: <Incoming Header Name>
Match Type: Equals
Header Value: <Incoming Header Name Value>
Case Sensitive: Off
Negate: Off
Match Strategy: ALL
Actions
Action: Select Pool
Select Pool: <Pool to send traffic to that matches the header>
Match Condition
Condition: HTTP Request Header
Header Name: Host
Match Type: Equals
Header Value: <Original host header value>
Case Sensitive: Off
Negate: Off
Match Strategy: ALL
Action: HTTP Request Header Rewrite
Header Name: Host
Header Value: <New host header value>
To verify the rules are working, enable Access Logging on the Virtual Server and check the Active Edge's log: /var/log/lb/<LB-ID>/<virtual server id>/logs/
Further details on configuring a Native Load Balancer rules can be found in section 7 here NSX-T LB 301 ToI / NSX-T LB Encyclopedia