Forum Discussion

kazeem_yusuf1's avatar
kazeem_yusuf1
Icon for Nimbostratus rankNimbostratus
Feb 28, 2017

AN IRULE THAT ADDS A STRING AS AN HTTP RESPONSE TO ANY POOL MEMBER CHOSEN BY THE F5

I need to load balance an application running on two pool members, 172.30.114.56:8080, 172.30.114.58:8080; However, on the two, i only get the page, "Tomcat is running".

 

However,the service only loads when i type either, 172.30.114.56:8080/arsys, or 172.30.114.58/arsys.

 

I need an irule that can add a string to the http response, such that, after the load-balancing decision,the string /arsys is added so, the page can load.

 

I don't know if the Stream Profile can work for this.

 

I tried the below irule, but its not working.

 

NOTE: VIP is 172.30.114.60.

 

when HTTP_REQUEST { if { [HTTP::host] equals "172.30.114.60" and [HTTP::uri] starts_with "/" } { HTTP::redirect ";; } } The requirement is that the service is to be accessed over https,but i still want to test basic http vip for it,172.30.114.60, but its not loading currently to any of the servers,

 

  • Given what you have said for the main VIP 172.30.114.60 try the following

    when LB_SELECTED {
      switch [LB::server addr] {
        "172.30.114.56" -
        "172.30.114.58" { if {[HTTP::uri] eq "/"} { HTTP::uri "/arsys" } }
      }
    }
    
  • when HTTP_REQUEST {
     if { [HTTP::uri] starts_with "/" } {
     This is to rewrite the URI to the NEW Arsys URI  
      log -noname local0. "Rewrite for / [HTTP::host] [HTTP::uri]"
      HTTP::uri "/arsys"
     This is to select the arsys POOL listening on 8080
      log -noname local0. "This was processed for Arsys"   
    
  • Hi,

    there is a problem with your condition... URI always starts with / 🙂

    when HTTP_REQUEST { 
        if { [HTTP::host] equals "172.30.114.60" and [HTTP::path] equals "/" } { 
            HTTP::redirect "/arsys" 
        } 
    }
    

    this irule will work with both HTTP and HTTPS

  • Thanks so much everyone, The irule finally worked. I made a mistake of adding the routes on the standby unit instead of the active unit.

     

    The headache that a little diligence can save.