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