F5 is upgrading its customer support chat feature on My.F5.com. Chat support will be unavailable from 6am-10am PST on 1/20/26. Refer to K000159584 for details.

Forum Discussion

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

beginner question - will this redirect work? or am I going to redirect right out of the f5?

im going to squeeze these 4 redirects on top of the existing pool switching Irule, but I dont really understand (yet) how the f5 processes Irules. Will the redirect kick the path right out of the f5 and to the servers? we do need these redirects to land into one of the below pools.... or will the redirect realize it needs to go to one of the pools below?

 

when HTTP_REQUEST {

 

redirects:

if {[HTTP::host] equals "ecms.epa.gov/erma/login.htm?action-search"}{HTTP::redirect "http://ecms.epa.gov/erma2/login.htm?action=search"}

 

if {[HTTP::host] equals "ecms.epa.gov/rradmin/login.htm?action=iss"}{HTTP::redirect "http://ecms.epa.gov/erma2/login.htm?action=registration"}

 

if {[HTTP::host] equals "ecms.epa.gov/rradmin/login.htm?action=orgadmin"}{HTTP::redirect "http://ecms.epa.gov/erma3/login.htm?action=orgadmin"}

 

if {[HTTP::host] equals "ecms.epa.gov/erma/login.htm?action=recordsadmin"}{HTTP::redirect "http://ecms.epa.gov/erma3/login.htm?action=recordsadmin"}

 

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 }

 

"/erma2" { /erma2 URI log local0. "[IP::remote_addr]: Request for /erma2 sent to pool pool_erma2_ecms.epa.gov_new_443" pool pool_erma2_ecms.epa.gov_443 } "/erma3" { /erma3 URI log local0. "[IP::remote_addr]: Request for /erma3 sent to pool pool_erma3_ecms.epa.gov_new_443" pool pool_erma3_ecms.epa.gov_443 }

 

"/erma*" { /erma URI log local0. "[IP::remote_addr]: Request for /erma sent to pool pool_erma_ecms.epa.gov_new_443" pool pool_erma_ecms.epa.gov_443 } default { everything else URI log local0. "[IP::remote_addr]: Default ecms.epa.gov sent to pool_default_ecms.epa.gov_new_443" pool pool_default_ecms.epa.gov_443 } } }

 

1 Reply

  • So I updated your iRule as I would do in my own environment. When doing an

    HTTP::redirect
    , you'll need to call the
    return
    command so the iRule stops processing that request. Otherwise you may run into issues later on in the iRule (yours would be fine, except that since it's a redirect, setting the pool is moot as the request will not make it to the server (it'll send back a redirect after the HTTP_REQUEST rule(s) finish).

    What I added was that if none of those redirectable urls were the requested one, do your switch and then set the pool as expected. That should get you the experience you are looking for.

    The other option would have been to separate the two switch statements completely and add a

    return
    command after each of the
    HTTP::redirect
    comamnds.

    when HTTP_REQUEST {
        switch [string tolower "[HTTP::host][HTTP::uri]"] {
            "ecms.epa.gov/erma/login.htm?action-search" {
                HTTP::redirect "http://ecms.epa.gov/erma2/login.htm?action=search"
            }
            "ecms.epa.gov/rradmin/login.htm?action=iss" {
                HTTP::redirect "http://ecms.epa.gov/erma2/login.htm?action=registration"
            }
            "ecms.epa.gov/rradmin/login.htm?action=orgadmin" {
                HTTP::redirect "http://ecms.epa.gov/erma3/login.htm?action=orgadmin"
            }
            "ecms.epa.gov/erma/login.htm?action=recordsadmin" {
                HTTP::redirect "http://ecms.epa.gov/erma3/login.htm?action=recordsadmin"
            }
            default {
                switch -glob -- [string tolower [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
                    }
                    "/erma2*" {
                         /erma2 URI
                        log local0. "[IP::remote_addr]: Request for /erma2 sent to pool pool_erma2_ecms.epa.gov_new_443"
                        pool pool_erma2_ecms.epa.gov_443
                    }
                    "/erma3*" {
                         /erma3 URI
                        log local0. "[IP::remote_addr]: Request for /erma3 sent to pool pool_erma3_ecms.epa.gov_new_443"
                        pool pool_erma3_ecms.epa.gov_443
                    }
                    "/erma*" {
                             /erma URI
                        log local0. "[IP::remote_addr]: Request for /erma sent to pool pool_erma_ecms.epa.gov_new_443"
                        pool pool_erma_ecms.epa.gov_443
                    }
                    default {
                         everything else URI
                        log local0. "[IP::remote_addr]: Default ecms.epa.gov sent to pool_default_ecms.epa.gov_new_443"
                        pool pool_default_ecms.epa.gov_443
                    }
                }
            }
        }
    }