Forum Discussion

TridipLenka_316's avatar
TridipLenka_316
Icon for Nimbostratus rankNimbostratus
Jul 12, 2017

iRule redirection to different port

i have configured a web service as below

 

VIP : abc.com:443

 

pool members: 10.100.10.1:8843 10.100.10.2:8843

 

but i want to redirect if any user comes with extension "xyz" as https://abc.com/xyz then it will re-direct to another port i.e https://10.100.10.1:7143 .

 

is it like i have to create a different pool for port 7143 and will call this pool in irule under https://abc.com please let me know what iRule should be used.

 

5 Replies

  • P_K's avatar
    P_K
    Icon for Altostratus rankAltostratus

    Creating a new pool and redirecting traffic based on your uri should work seamlessly.

     

    when HTTP_REQUEST {

     

    if { [string tolower[HTTP::host] eq "abc.com"] && [string tolower[HTTP::uri] starts_with "xyz" ] } {

     

    pool pool_7143

     

    }

     

    else {

     

    pool default_pool

     

    }

     

    }

     

  • Hi,

     

    You dont need to create a separate pool for it. You can just create a node for the same

     

    when HTTP_REQUEST { if {[string tolower[HTTP::host] eq "abc.com"] && [string tolower[HTTP::uri] starts_with "xyz" ] } { node 10.100.10.1 7143 } else { pool default_pool } }

     

  • Try adding a logging to see how the F5 is interpreting the request:

    when HTTP_REQUEST {
      log local0. "URI:[HTTP::uri]"
      if { [HTTP::uri] starts_with "/xyz" } {
        node 10.202.100.1 7143
      } else {
        pool Default_pool
      }
    }
    
  • The iRule should be working as written. You could use tcpdump to confirm if traffic is getting sent to the node specified in the iRule.

     

    tcpdump -nni 0.0 host 10.202.100.1

     

  • You'll need to modify the log to output the URI that is captured in the else condition. Once a match is made in an 'if' statement it breaks out and stops processing further conditions so the 'else' should not be matched if it was previously matched in the preceding 'if'

    when HTTP_REQUEST {
      if { [HTTP::uri] starts_with "/xyz" } {
        log local0. "If condition matched with URI:[HTTP::uri]"
        Pool abc_pool
      } else {
        log local0. "else condition matched with URI:[HTTP::uri]"
        pool Default_pool
      }