Using aFlex to generate custom redirect URI

jfsvjfsv Member ✭✭
Hello,

I would like to use aFlex to re-write a URL redirect using the name of each server in a service group. For example, I have virtual_serverA and multiple serverX (server1, server2, server3, etc.) in a service group. The A10 is configured to actively check the health of these servers.

When someone connects to virtual_serverA I want the A10 to pick one of the available servers that is passing health checks in the service group and return an HTTP 302 Found with Location: http://serverX. I want the script to get the server name from the A10 configuration. I don't want to have to maintain a separate list somewhere since I would need to update that list anytime the number of servers changed.

Unfortunately, I cannot install any additional services on the servers. So creating a virtual server on each server to return the HTTP 302 is not possible.

After fiddling around for a few hours I was finally able to create this simple aFlex script:

when HTTP_REQUEST {
HTTP::uri "/desktop"
}
when HTTP_RESPONSE {
HTTP::respond 302 Location "https://[LB::server name]/desktop"
}

This script rewrites the original URI so the user can't put in something crazy and cause issues on the servers. When the response comes back from the server the script does rewrite the response using one of the available servers in the service group. So this is working.

However, I would like to have a script that is not required to send traffic to a server just to get a response the script is going to throw away. I'd like to be able to have the A10 pick a server then execute HTTP::respond immediately. "LB::server name" does not work in event HTTP_REQUEST because the A10 hasn't selected a server when this event is triggered. I tried using events LB_SELECTED and HTTP_REQUEST_SEND but was unable to use HTTP::respond or HTTP::redirect as they don't seem to be supported for these event.

Any ideas on how to get the A10 and aFlex to select a server THEN return a redirect using the configured server name WITHOUT sending a request to the backend server?

Any help is appreciated.
John
Sign In or Register to comment.