Forum Discussion

RandyTittleman's avatar
RandyTittleman
Icon for Altostratus rankAltostratus
Apr 17, 2019

Using LTM Policy to Redirect Host But Preserving Original URI

I am looking for some guidance and hopefully the community can help.

 

We are trying to perform a host redirect using an LTM policy. The requirements are as follows:

 

  • If URL contains uri /thisuri, forward request to pool http_server.
  • If URL contains uri that is not /thisuri, redirect request to https://www.domain.com/[orginal_uri]

We managed to configure our LTM policy to do everything except preserve the URI in the original request if URI is not /thisuri. Is preserving the URI from the original client request even possible when using an LTM policy? Has anyone tried doing something like this before?

 

Our current logic is like this (we are using first match policy strategy):

 

1.test_uri_redirect Match all the following conditions

 

HTTP URI > path > is > any of > /thisuri at request time.

 

Do the following when the traffic is matched

 

Forward Traffic > to pool > /Common/https_server > at request time.

 

2.test_host_redirect Match all the following conditions

 

HTTP URI > path > is not > any of > /thisuri > at request time.

 

Do the following when the traffic is matched

 

Redirect > to location https://www.domain.com > at request time.

 

All that we are missing is how to tell the BIG-IP to preserve the original URI path. Any help would be much appreciated.

 

  • this TCL expression no longer works on TMOS 15

     

    Tcl expression: 'command is not valid in current event context (HTTP_RESPONSE): HTTP::uri'.

    • Peter_Z's avatar
      Peter_Z
      Icon for Cirrus rankCirrus

      Doesn't seem to be version related problem to me. It seems more like the HTTP::uri command is executed from incorrect EVENT - it should be executed within HTTP_REQUEST event not within HTTP_RESPONSE.