Forum Discussion

Preet_pk's avatar
Preet_pk
Icon for Cirrus rankCirrus
Apr 25, 2022
Solved

Host based irule & URI to point to backend pool

Hi,

We have a requirement to forward application access to backend server pool based on "host" and "uri".

Below is the requirement.

If host is "abc.local.ae" & uri is "/malla"  -> then pool - "abc-pool:8080"

If host is "abc.local.ae" & uri is "/mise"  -> then pool - "abc-pool:8081"

Please let me the iRule syntax whih will meet the above requirement.

 

 

  • Hi Preet_pk 

    If site/url is not working after mapping pool directly to the vServer then the issue is something else. 

    Can you verify below configurations ?

    1. SNAT settings on the vServer. If backend server's default gateway is not F5 then make sure to enable SNAT settings. You can set it to AUTOMAP.

    2. Is your pool showing up on the F5? Check if you have correct routing on the F5 to reach backend server.

    Once this is sorted. then you can test the iRule.

7 Replies

  • Hi,

    Does this have to be done by a irule.
    it can be done very quickly and easily using a local traffic policy.

    I can send you some config, if it can be a LTP not a iRule. (I'm not on top of irules yet!)

    • PSFletchTheTek's avatar
      PSFletchTheTek
      Icon for MVP rankMVP

       

       Here you go, something like this. (Wanted to try the new devcentral out with photos! Very easy now!)

       

    • lanruibin's avatar
      lanruibin
      Icon for Nimbostratus rankNimbostratus

      I would like to know the difference between http-URI /a and /a/, thank you

  • Hi Preet_pk ,

    I agree with PSFletchTheTek , LTM policy will be more easier & also those are more faster when it comes to execution. Still if you want to user iRule, you can refer below irule for your use case.

     

    when HTTP_REQUEST {
    
    if {[HTTP::host] equals "abc.local.ae"} {
        
        if {[HTTP::uri] contains "malla"} {
           
            pool abc-pool:8080
        } elseif {[HTTP::uri] contains "mise"} {
            
            pool abc-pool:8081
        } 
    }
    
    }

    Hope it helps!

    • Preet_pk's avatar
      Preet_pk
      Icon for Cirrus rankCirrus

      Hi,

      Thanks for sharing the irule, tested the irule but it is not work. Below is the configuration details. Tried creating seperate VS & applied pool abc-pool:8080 directly for tesing instead of irule - still it is not working. Please let me know if F5 will not process traffic if, we are using port 443 on VS &  backend server on port 8080 - as i am not able to see any traffic statistics on pool members while testing the connectivity & in browser getting "PR_CONNECT_RESET_ERROR" . Even in Packet capture can see F5 VS ip resetting the traffic to client ip address - instead of processing backend server connectivity.

      VS:

      10.120.10.10    Port 443

      Backend irule:

      when HTTP_REQUEST {

      if {[HTTP::host] equals "abc.local.ae"} {

      if {[HTTP::uri] contains "malla"} {

      pool abc-pool:8080
      } elseif {[HTTP::uri] contains "mise"} {

      pool abc-pool:8081
      }
      }

      }

       

       

  • Hi Preet_pk 

    If site/url is not working after mapping pool directly to the vServer then the issue is something else. 

    Can you verify below configurations ?

    1. SNAT settings on the vServer. If backend server's default gateway is not F5 then make sure to enable SNAT settings. You can set it to AUTOMAP.

    2. Is your pool showing up on the F5? Check if you have correct routing on the F5 to reach backend server.

    Once this is sorted. then you can test the iRule.

    • Preet_pk's avatar
      Preet_pk
      Icon for Cirrus rankCirrus

      Hi,

      Thanks for the details. Issue is sorted out - issue was due to missing route to backend application server subnet in F5.