IRule for backend server with multiple ports and / URI

We have VIP- vs_172.18.92.199_HTTPS on LB and its allowing the URL- http://172.18.100.205:8089/sso/ using configured IRLUE. Now after login into this page, we have TAB=link for same backend server: http://172.18.100.205:8086/cvbs/ and one more TAB for another URL- http://172.18.100.200:8080/m2m_op.

Now--end user only having access to LB IP- 172.18.92.199 and needs to achieve this, please support.

Current IRULE:

when HTTP_REQUEST { if { [HTTP::uri] starts_with “/sso” } {

} else {
    HTTP::uri "/sso"
}

}

==> want to deploy like this: (if URL A:8089, then check uri, if /sso/, good else set uri /sso/) IF URL A:8086, Check URI if /cvbs/… and lastly (IF URL B:8080, if /m2m_op/ … )

and create an out. Else: set URL URL A: set URI /sso/ or some other "if it doesn’t match any of these, reset the connection.

Hi,

you can mix switch, if/else commands to achieve your goal. You can have a look at the code published by Kevin here : Use switch for multiple conditions

something like this should work:

when HTTP_REQUEST {
      log local0. "HTTP Uri: [HTTP::uri]"
          set xxxx [URI::query [HTTP::uri] yyy]
      if { [matchclass [HTTP::uri] contains blah] } {

        redirect to "https://www.hello.com"
      } elseif { 
               [matchclass  [HTTP::uri] contains ZZZZ] } {
         log local0. "something to log
          redirect to "https://www.somethingelse.com"     
          } else {
             redirect to "https://www.final.com"
      }
    }

Hi,

Do you have only one virtual server on port 80 (or 443) or do you have multiple virtual servers on ports 8080, 8086 and 8089???

you can create an irule like:

when HTTP_REQUEST { 
    switch -glob [HTTP::path] 
        "/sso*" {
            pool pool1
        }
        "/cvbs/*"  {
            pool pool2
        }
        "/m2m_op/*" {
            pool pool3
        }
        default {
            HTTP::redirect /sso
        }
    }
}

It’s not a good idea to replace HTTP::uri but better to send to the browser that the URI is redirected to /sso