sharedvar

Description

Allows a variable to be accessed in both sides of a VIP-targetting-VIP

Syntax

sharedvar <variable name>

sharedvar <variable name>

  • Shares a variable between both connections when a VIP targets another VIP. Note that both virtuals must declare the variable as shared for the data to be shared.

Examples

Virtual vip1:
when HTTP_REQUEST {
   sharedvar public
   set private "data for vip1 only"
   set public "data for vip1 and vip2"
   virtual vip2
}
when HTTP_RESPONSE {
   log local0. "vip1 @ response: private: $private"
   log local0. "vip1 @ response: public: $public"
}

Virtual vip2:
when HTTP_REQUEST {
   sharedvar public
   if { [info exists private] } {
     log local0. "vip2 @ request: private: $private"
   } else {
     log local0. "vip2 @ request: private does not exist"
   }
   if { [info exists public] } {
     log local0. "vip2 @ request: public: $public"
   } else {
     log local0. "vip2 @ request: public does not exist"
   }
}
when HTTP_RESPONSE {
   set private "vip2 private data"
   set public "vip2 public data"
   log local0. "vip2 @ response: private: $private"
   log local0. "vip2 @ response: public: $public"
}

An HTTP request to VIP1 will log:
Rule share2 <HTTP_REQUEST>: vip2 @ request: private does not exist
Rule share2 <HTTP_REQUEST>: vip2 @ request: public: data for vip1 and vip2
Rule share2 <HTTP_RESPONSE>: vip2 @ response: private: vip2 private data
Rule share2 <HTTP_RESPONSE>: vip2 @ response: public: vip2 public data
Rule share1 <HTTP_RESPONSE>: vip1 @ response: private: data for vip1 only
Rule share1 <HTTP_RESPONSE>: vip1 @ response: public: vip2 public data