Forum Discussion

Lance_Simon_557's avatar
Lance_Simon_557
Historic F5 Account
May 03, 2007

redirect iRule to different uri

have a vip on port 80

 

pool members on port 50100

 

 

need to have this come to the vip

 

http://sapxpq.browning.k12.ia.us

 

and redirect it to

 

http://sapxpq.browning.k12.ia.us:50100/irj/portal

 

 

what is the simplest way of accomplishing this?

 

 

Thanks
  • This will do what you are asking:

    
    when HTTP_REQUEST {
      if { ([HTTP::host] eq "sapxpq.browning.k12.ia.us") and [HTTP::uri] < 2 } {
        HTTP::redirect "http://sapxpq.browning.k12.ia.us:50100/irj/portal"
      }
    }

    However, is this really what you want? You will need a virtual listening on port 50100 as well, or the virtual setup originally will have to listen on port 0 so that port 80 and port 50100 can be accomodated.

    The LTM will do the port redirection for you, so if that is your concern, you could just redirect them to http://sapxpq.browning.k12.ia.us/irj/portal and the requests will look like this:

    Hitting LTM:

    http://sapxpq.browning.k12.ia.us:80/irj/portal

    Hitting Server:

    http://server_IP:50100/irj/portal

    HTH....Jason

  • Try this:

     

     

    when HTTP_REQUEST {

     

    set uri [string tolower [HTTP::uri]]

     

    if { $uri equals "/" } {

     

    pool somepool_50100_pool

     

    HTTP::redirect "/irj/portal"

     

    }

     

    }

     

     

    Kevin
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    Hey Lance --

    Both rules take the right approach for the simple redirect you requsted, but since HTTP/1.1 requires an absolute redirect, I'd recommend citizen_elah's post with one modification:

    Change
    [HTTP::uri]
    to
    [string length [HTTP::uri]]
    to test whether the URI is longer than "/".

    (And I agree that the customer may not yet have given you a complete and accurate description of his requirements...)

    HTH

    /deb