Forum Discussion

AP_5759's avatar
AP_5759
Icon for Nimbostratus rankNimbostratus
Jun 15, 2017

Help with iRules and URI redirection

Hello everyone. I am looking for help with irule design to perform the following: remove "services" from uri and forward traffic to a specific pool as following

http://dev.api.company.com/services/nameofservice1
http://dev.api.company.com/services/nameofservice2
http://dev.api.company.com/services/nameofservice3
http://dev.api.company.com/services/nameofservice4
http://dev.api.company.com/services/nameofservice5

pool1_8888
pool2_8889
pool3_8890
pool4_8891
pool5_8892

dev.api.company.com/services/nameofservice1 ==> dev.api.company.com/nameofservice1 ==> pool1_8888
dev.api.company.com/services/nameofservice2 ==> dev.api.company.com/nameofservice2 ==> pool2_8889
dev.api.company.com/services/nameofservice3 ==> dev.api.company.com/nameofservice3 ==> pool3_8890
dev.api.company.com/services/nameofservice4 ==> dev.api.company.com/nameofservice4 ==> pool4_8891
dev.api.company.com/services/nameofservice5 ==> dev.api.company.com/nameofservice5 ==> pool5_8892

Any help and/or assistance will be greatly appreciated. Thank you all.

3 Replies

  • Sorry, forgot to add.. I need to perform the port translation. The browser should not see theother ports except of 80. Thank you again.

     

  • This should provide a rough idea. Create a datagroup: CLASS_URI_POOL

    /services/nameofservice1:=pool1_8888
    /services/nameofservice2:=pool2_8889
    /services/nameofservice3:=pool3_8890
    /services/nameofservice4:=pool4_8891
    /services/nameofservice5:=pool5_8892
    
    when HTTP_REQUEST {
    set POOL [class match -value $URI contains CLASS_URI_POOL]
    if { $POOL eq "" } {
    HTTP::uri [string map {/services/ /} [HTTP::uri]]
    pool $POOL
    }
    }
    
  • Appreciate a prompt response. I will modify this rule and will give it a try.