Version notice:
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
Related Information¶
Valid Events:
Warning
The links to the sample code below are remnants of the old DevCentral wiki and will result in a 404 error. For best results, please copy the link text and search the codeshare directly on DevCentral.
Sample Code:
- Introduced: BIGIP-10.1.0
The BIG-IP API Reference documentation contains community-contributed content. F5 does not monitor or control community code contributions. We make no guarantees or warranties regarding the available code, and it may contain errors, defects, bugs, inaccuracies, or security vulnerabilities. Your access to and use of any code available in the BIG-IP API reference guides is solely at your own risk.