Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I currently have several F5 BigIP LTM pools of Windows servers. There is a high level IIS config setting on each server that adds a header to identify the server from which the response came.

<customHeaders>
    ...
    <add name="X-Server-Name" value="WEB01P" />
</customHeaders>

I want to move this customization onto the LTM using an iRule. Like IIS is doing server by server, the iRule should add a response HTTP header indicating which server is handling the request based on the load balancing decision made by the LTM.

I did some searching and read the documentation for iRule variables and commands. There is an iRule command for server action/information: LB::server. According to the documentation:

This command allows you to query for information about the member selected after a load balancing decision has been made.

This command includes these two sub commands:

LB::server

returns a Tcl list with pool, pool member address and port. If no server was selected yet or all servers are down, returns default pool name only.

LB::server name

returns a Tcl list with pool, pool member address and port. If no server was selected yet or all servers are down, returns default pool name only.

I noted the duplicate descriptions and figured that it was simply a documentation error. I figured that server name would actually give me the server name the LTM chose. So between the docs and some threads in the F5 dev forums, I came up with this iRule:

when HTTP_RESPONSE {
   # Replace (or insert if it doesn't exist) a custom HTTP header with the selected server name
   HTTP::header replace X-Server-Name "[LB::server name]"
}

However, the response we are getting looks like this:

X-Server-Name   OurVirtualServerPoolName 10.160.252.255 80

The IP address is for a selected server, so that is somewhat helpful. But I'd much rather have the server name.

I can not find any other command or command options that suggest they'll return the name of the server instead of just the IP.

Does anyone know how to accomplish this?

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.