ADC

Example 8: Redirect Queries to the Queried Server

Example Inc. wants to redirect query requests to the appropriate server, as shown here.

  • <Request: GET /query.cgi?server=5HOST: www.example.com
  • <Redirect URL: <http://web-5.example.com/>

To implement this redirection, you would first create a rewrite action with the values in the following table.

Action Name Type of Rewrite Action Expression to choose target reference String expression for replacement text
Action-Rewrite-Replace_Hostheader REPLACE HTTP.REQ.HEADER(“Host”).BEFORE_STR(“.example.com”) “server-“ + HTTP.REQ.URL.QUERY.VALUE(“web”)

You would then create a rewrite policy with the values in the following table.

Policy Name Action Name Undefined Action Expression
Policy-Rewrite-Replace_Hostheader Action-Rewrite-Replace_Hostheader NOREWRITE HTTP.REQ.HEADER("Host").EQ("www.example.com")

Example commands:

> add rewrite action Action-Rewrite-Server_Mask REPLACE HTTP.RES.HEADER("Server") "\"Web Server 1.0\"" Done

> add rewrite policy Policy-Rewrite-Server_Mask HTTP.RES.IS_VALID Action-Rewrite-Server_Mask NOREWRITE Done

Finally, you would bind the rewrite policy, assigning it a priority of 900. Because this policy should be the last policy applied to a request that matches its criteria, you set the goto expression to END.

Incoming requests to any URL that begins with http://www.example.com/query.cgi?server are redirected to the server number in the query.

Example 8: Redirect Queries to the Queried Server