Forum Discussion

8 Replies

  • John_Alam_45640's avatar
    John_Alam_45640
    Historic F5 Account

    Assuming that the user lands on a BigIP virtual after being redirected.

     

    Normally there is nothing in the request to indicate how a user landed on a site. If however, the server which sent the redirect is being proxied by a BigIP, you can intercept the redirect and include a some tracer. The best way here may be to include a special query parameter. When the bigip receives the request, it will detect the parameter and act on that. The bigIP can also strip the query parameter before sendging to backend so application does not see it.

     

    HTH

     

    • Rajesh_A_142089's avatar
      Rajesh_A_142089
      Icon for Nimbostratus rankNimbostratus
      Thank you John. Yes the redirect is initiated by the same BigIp and the Redirect Site is also being served by the same BigIP. In this scenario I am thinking of best approach to include something in the redirect to let the new request on the redirect know its a sort of 302 request.... I will post my findings here later...
  • Not generally possible. A 30x redirect results in an atomically new request to the stated resource. The only other potentially useful information might be a Referer header, but that's not consistent. If you have control of the service generating the redirect, and the destination service is in the same domain, you could potentially drop a cookie in the redirect and pick it up in the next new request. There might also be a client side JavaScript option, but not 100% certain.

     

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus
    Note that 301 is a permanent redirect (i.e. it may be cached). 302 and 307 are the most common temporary redirects.
  • John_Alam_45640's avatar
    John_Alam_45640
    Historic F5 Account

    Append a parameter to the Location header like this:

    when HTTP_RESPONSE {
        If {  [HTTP::is_redirect] } {
            HTTP::header replace Location "[HTTP::header Location]?type=redirected"
        }
    }
    

    See this: https://devcentral.f5.com/wiki/iRules.http__is_redirect.ashx

    If there are already some parameters in the location header then use this instead:

    HTTP::header replace Location "[HTTP::header Location]&type=redirected"

    • Rajesh_A_142089's avatar
      Rajesh_A_142089
      Icon for Nimbostratus rankNimbostratus
      Thank you John. Following your advise, I have following in my RESPONSE event where I needed to redirect the response somewhere temporarily (302) and also this is where I wanted to indicate in the redirect that it is redirect.. The result is that redirect happens but I do not see the query string in my redirect.. Please advise....Am I embading the header appropriately? when HTTP_RESPONSE { if { $is_sourcehost and [HTTP::status] == 404 } { HTTP::header replace Location "[HTTP::header Location]?type=redirected" HTTP::respond 302 noserver Location "https://temlocation.mydomain.com$uri" } }