Forum Discussion

nrg2brn_163859's avatar
nrg2brn_163859
Icon for Nimbostratus rankNimbostratus
Mar 10, 2015

I just did my first (pool switching) irule, now they threw me a curve ball.

I was feeling pretty good with my little irule that, depending on the first few letters of the uri would switch pools:

 

when HTTP_REQUEST { Check the requested path with wildcard matching switch -glob [HTTP::path] { "/rradmin*" { /rradmin URI log local0. "[IP::remote_addr]: Request for /rradmin sent to pool pool_rradmin_ecms.gov_new_443" pool pool_rradmin_ecms.epa.gov_443

 

...and so on. had a few other ones, erma*, etc...NOW they want actual redirects. what I dont understand is, how can I do a redirect like:

 

if the user types in http://ecms.epa.gov/erma /login.htm?action=search then redirect them to: http://ecms.epa.gov/erma2/login.htm?action=search

 

wont this bypass the ltm basically? its not going to send it to a pool. IM pretty sure IM missing a big concept here, and Ill keep reading, but if someone could whack hit me in the right direction, it would help.

 

thanks!

 

dave

 

6 Replies

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus

    If the IP-address of ecms.epa.gov is routed through the BIG-IP (i.e. a VIP) it doesn't matter what path is used; all requests will be handled by that VIP.

     

    Redirects are directives that tell the client (usually a web browser) to try the request at a different URL. If it's using the same domain name it will likely be handled by the same VIP.

     

  • Hi Dave,

    an iRule to handle this request would look like this:

    when HTTP_REQUEST {
       if {([string tolower [HTTP::host]] equals "ecms.epa.gov") and 
           (([string tolower [HTTP::path]] equals "/erma/login.htm") and 
            ([string tolower [HTTP::query]] contains "action=search"))} {
          HTTP::redirect "http://ecms.epa.gov/erma2/login.htm?action=search"
          return
       }
    }    
    

    It will check the host-header, the path and the query (URI includes path and query separated by question mark).

    For a match it will redirect the client.

    In case of no match it will proceed and end up with the default action i.e. leaving it to the virtual server to forward to the default pool.

    Thanks, Stephan

    2015-03-11: Edited according to Arie´s advice.

  • ([string tolower [HTTP::query]] contains "?action=search"))} {

    i think HTTP::query does not include question mask (?).

    [root@ve11c:Active:In Sync] config  tail -f /var/log/ltm
    Mar 11 12:59:13 ve11c info tmm[15262]: Rule /Common/qux : [HTTP::uri]=/erma/login.htm?action=search  [HTTP::path]=/erma/login.htm  [HTTP::query]=action=search
    
  • ([string tolower [HTTP::query]] contains "?action=search"))} {

    i think HTTP::query does not include question mask (?).

    [root@ve11c:Active:In Sync] config  tail -f /var/log/ltm
    Mar 11 12:59:13 ve11c info tmm[15262]: Rule /Common/qux : [HTTP::uri]=/erma/login.htm?action=search  [HTTP::path]=/erma/login.htm  [HTTP::query]=action=search