Forum Discussion

tidenz_92110's avatar
tidenz_92110
Icon for Nimbostratus rankNimbostratus
May 31, 2011

Insert header into response based on pool selected in request.

Hi Guys,

 

 

I am looking for a way to insert a header into the response based on the pool member selected in the request.

 

 

The scenario is we are implementing service stacks and the developers want to know which stack is active.

 

 

So ideally they have asked if we can output a header either a 1 or 0 depending on which stack/pool member the request is load balanced to.

 

 

I know i can match the pool member out of an data class but i am not sure of the syntax/variable that will allow me to check/log the member that the request was load balanced too.

 

 

Thanks

 

 

2 Replies

  • Hi Tidenz,

     

    I can think of 2 ways to do this.

     

     

    1) If the LTM version you are using is 10.1 you can use the HSL commands that can help you send data within iRules that can be reviewed by developers. Click Here if you want to see a video article about this.

     

     

    2) If your service is a HTTP based - You can insert custom headers as you mentioned for which developers can pickup on and report via webpage code and display it against a footer or header banner.

     

     

    I hope this helps

     

    Bhattman

     

  • You could do this in HTTP_RESPONSE. Here's a simple example which inserts the server IP:port in a header named SERVER_INFO:

    when HTTP_RESPONSE {
    
       HTTP::header insert SERVER_INFO "[IP::server_addr]:[TCP::server_port]"
    }
    

    If you wanted to map the server IP:port to a name or some other value, you could create the mapping in a string datagroup and then use the class command (in v10) or the findclass command (in v9) to do the lookup.

    Aaron