Forum Discussion

VAF's avatar
VAF
Icon for Nimbostratus rankNimbostratus
May 26, 2021

Select a pool member based on URI and remove the URI info

We have one virtual server with multiple pool members. Currently, the site is functioning with an irule that inserts a header and selects a pool member round robin. We would like to select a specific pool member based on the uri. The goal is for a user to be able to append a server name as the URI and the correct pool member is then selected. If the web site is mysite.com, the user can append mysite.com/server1 to select the pool member associated with that server. The URI would then be stripped from URL so it reaches the backend server as mysite.com.

Note: An access policy is being used for this virtual server/site.

 

I initially started with using when HTTP_REQUEST, but found that would not work correctly with an access policy and the APM in use. I then used the ACCESS_ACL_ALLOWED. It now lands on the correct pool member page, but the page stays stuck at "Loading". The header info is inserted within this event, but I am not sure if it should be within another event? The current implementation is shown below.

 

 

when ACCESS_ACL_ALLOWED {

  switch -glob [string tolower [HTTP::path]] {

    "/server1" {

               HTTP::path "/"

                 pool test_pool member 111.111.111.111:8000

                 }

    "/server2" {

                HTTP::path "/"

                 pool test_pool member 222.222.222.222:8000

                 }

   }

set username [string tolower [ACCESS::session data get session.ldap.last.attr.employeeID]]

HTTP::header insert X-Remote-User $username

}

 

18 Replies

  • VAF's avatar
    VAF
    Icon for Nimbostratus rankNimbostratus

     

    I checked & verified the cookie name and the value. I also thought that maybe the settings for the cookie may need to be changed. Does this look right?

  • VAF's avatar
    VAF
    Icon for Nimbostratus rankNimbostratus

    Nicolas,

     

    Again. I much appreciate the effort you have put into this.

     

    Here is what I have done based on your suggestions.

     

    I did open up the developer tools in the browser. Private browser setting is not available on any of our browsers in our work environment. However. I believe I could see all the info you described.

     

    First, I set the cookie profile for this virtual server to not do encryption in order to check/verify the value setting. I then went back to the working environment (no local traffic policy, irule only doing header insert, landing on round robin backend server). I could view the cookie as you described. It is set in the response and then the next time, it is sent in the request. I verified that this is the value that I use when I apply the local traffic policy. All that matches and looks good (name, values)

     

    Then, I implemented the policy and the irule with the catch LB. Again I could see the correct cookie being set and then sent in the subsequent request. However, there is still the same issue with the load balancer selecting a backend server in the same round robin fashion as before.

     

    I can send you screen shots, but it all looked good and matched what you showed.

     

    This is a production application that is on a time line. Although the idea of having one virtual server with a user being able to add a uri to select a specific backend would have been the preferred solution, this does not appear to be doable on the F5 LTM, possibly because of using an access policy? We know that we can get this to work with having one virtual server per backend server. Although this means 10+ virtual servers, a solution we really didn't want, a working solution is better than a non-working solution, especially because this would have been in place weeks ago.

     

    If you have any thoughts on how this could be accomplished without having one virtual server per backend server, that would be appreciated. I probably haven't considered other possible (working) solutions.

  • VAF's avatar
    VAF
    Icon for Nimbostratus rankNimbostratus

    Nicolas,

     

    I finally noticed the behavior of this application. I now have three backend servers in the pool. I have three rules in the policy, one for each backend server. Here is what happens:

     

    Open web browser, enter the url with one of the server names, let's say 008. the F5 appears to round robin this and lands on any of the three backend servers. However, if I keep the browser open and enter the url of any of the three backend servers it will then go to the correct one from that point on.

     

    So basically this:

    Open browser - select mysite.com/008 - F5 LTM load balances to any of three in pool

    With browser still open enter mysite.com/009 - click Refresh, correct backend server loads

    Enter mysite.com/012 - refresh - correct backend server

    and so forth

     

     

     

    So, after initial landing which is round robining from pool, it then works if one does NOT close the browser and enters one of the three urls.

    Also, after initial check for credentials, it doesn't ask again after first landing on round robined backend server, so jumping to the different servers is quick.

    • Hi !

      Nice to see you going forward !

      Even if it looks like some stuff may still need to be fix.

      However when you says that the first time you go to mysite.com/008 you do not land on the correct node but you do after refreshing the page make me thinking that maybe when you think you get round -robined to a wrong node it is indeed your browser using previous data from it's local cache.

       

      Regards,

  • VAF's avatar
    VAF
    Icon for Nimbostratus rankNimbostratus

    Nicolas.

     

    Any ideas on the solution for the caching issue. Note. Each time I access the site it is after browser has been closed and then restarted, so a completely fresh opening of a browser (any browser). What else could be done to stop that from occurring? Is there anything else that could be affecting this? http profile, some setting?