An HTTP request rewrite is applied to the HTTP request coming from the client.

Prerequisites

Verify that a Layer 7 HTTP virtual server is available. See Add Layer 7 HTTP Virtual Servers.

Load Balancer rules support REGEX for match types. PCRE style REGEX patters is supported with a few limitations on advanced use cases. When REGEX is used in match conditions, named capturing groups are supported. See Regular Expressions in Load Balancer Rules.

Procedure

  1. Open the Layer 7 HTTP virtual server.
  2. In the Load Balancer Rules section, next to Request Rewrite Phase, click Set > Add Rule to configure the load balancer rules for the HTTP Request Rewrite phase.
  3. From the drop-down list, select a match condition. Match conditions are used to match application traffic passing through load balancers. Multiple match conditions can be specified in one load balancer rule. Each match condition defines a criterion for application traffic.
    Supported Match Condition Description
    HTTP Request Method Match an HTTP request method.

    http_request.method - value to match

    HTTP Request URI Match an HTTP request URI without query arguments.

    http_request.uri - value to match

    HTTP Request URI Arguments

    Used to match URI arguments aka query string of HTTP request messages, for example, in URI http://exaple.com?foo=1&bar=2, the "foo=1&bar=2" is the query string containing URI arguments. In an URI scheme, query string is indicated by the first question mark ("?") character and terminated by a number sign ("#") character or by the end of the URI.

    http_request.uri_arguments - value to match

    HTTP Request Version Used to match the HTTP protocol version of the HTTP request messages

    http_request.version - value to match

    HTTP Request Header Used to match HTTP request messages by HTTP header fields. HTTP header fields are components of the header section of HTTP request and response messages. They define the operating parameters of an HTTP transaction.

    http_request.header_name - header name to match

    http_request.header_value - value to match

    HTTP Request Cookie Used to match HTTP request messages by cookie which is a specific type of HTTP header. The match_type and case_sensitive define how to compare cookie value.

    http_request.cookie_value - value to match

    HTTP Request Body Match an HTTP request body content.

    http_request.body_value - value to match

    Client SSL Match client SSL profile ID.

    ssl_profile_id - value to match

    TCP Header Port Match a TCP source or the destination port.

    tcp_header.source_port - source port to match

    tcp_header.destination_port - destination port to match
    IP Header Source Matches IP header fields in of HTTP messages. The source type must be either a single IP address, or a range of IP addresses, or a group. See Add a Group.
    • If IP Header Source is selected, with an IP Address source type, the source IP address of HTTP messages should match IP addresses which are configured in groups. Both IPv4 and IPv6 addresss are supported
    • If IP Header Source is selected with a Group source type, seelct the group from the drop-down list.

    ip_header.source_address - source address to match

    ip_header.destination_address - destination address to match
    Variable Create a variable and assign a value to the variable.
    Case Sensitive Set a case-sensitive flag for HTTP header value comparison. If true, case is significant when comparing HTTP body value.
  4. From the drop-down menu, select a Match Type: starts with, ends with, equals, contains, or matches regex. Match type is used to match a condition with a specified action.
    Match Type Description
    Starts With If the match condition starts with the specified value, the condition matches.
    Ends With If the match condition ends with the specified value, the condition matches.
    Equals If the match condition is the same as the specified value, the condition matches.
    Contains If the match condition contains the specified value, the condition matches.
    Matches Regex If the match condition matches the specified values, the condition matches.
  5. Specify the URI.
  6. From the drop-down menu, select a Match Strategy:
    Match Strategy Description
    Any Indicates that either host or path can match for this rule to be considered a match.
    All

    Indicates that both host and path must match for this rule to be considered a match.

  7. Select an Action from the drop-down menu:
    Actions Description
    HTTP Request URI Rewrite

    This action is used to rewrite URIs in matched HTTP request messages. Specify the URI and URI Arguments in this condition to rewrite the matched HTTP request message's URI and URI arguments to the new values. Full URI scheme of HTTP messages have following syntax: Scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment The URI field of this action is used to rewrite the /path part in the above scheme. The URI Arguments field is used to rewrite the query part. Captured variables and built-in variables can be used in the URI and URI Arguments fields.

    1. Enter the URI of the HTTP request
    2. Enter the query string of URI, which typically contains key value pairs, for example: foo1=bar1&foo2=bar2.
    HTTP Request Header Rewrite

    This action is used to rewrite header fields of matched HTTP request messages to specified new values.

    1. Enter the name of a header text box HTTP request message.
    2. Enter the header value.
    HTTP Request Header Delete

    This action is used to delete header fields of HTTP request messages at HTTP_REQUEST_REWRITE phase. One action can be used to delete all headers with same header name. To delete headers with different header names, multiple actions must be defined.

    • Enter the name of a header field of HTTP request message.
    Variable Assignment Create a variable and assign it a name and value.
  8. Toggle the Case Sensitive button to set a case-sensitive flag for HTTP header value comparison.
  9. Toggle the Negate button to enable it.
  10. Click Save and Apply.