Forum Discussion
user1115_113077
Nimbostratus
Jun 25, 2011Help with Cookie Insertion
Hello,
Currently we're using the following on a vs,
when HTTP_REQUEST {
if { [HTTP:uri] starts_with "/clasee*"} {
pool class} ...
The_Bhattman
Nimbostratus
Jun 26, 2011Hi User1115,
For debugging you can do the following:
This is for version 9.x.x
when HTTP_REQUEST {
Insert cookie if it matches the CLASS_IP datagroup
if { [matchclass [IP::client_addr] eq $::class_ip] } {
HTTP::cookie insert name "class" value "class"
log local0. "The Source IP: [IP::client_addr] matched. Inserting Cookie"
}
Choose a pool based on URI
if { [HTTP::uri] starts_with "/clasee*"} {
log local0. "The URL is [HTTP::uri] which is selecting pool class"
pool class
} else {
log local0. "the URL is [HTTP::uri] which is selecting pool main"
pool main
}
}
OR Using a switch statement
when HTTP_REQUEST {
Insert cookie if it matches the CLASS_IP datagroup
if { [matchclass [IP::client_addr] eq $::class_ip] } {
log local0. "The Source IP: [IP::client_addr] matched. Inserting Cookie"
HTTP::cookie insert name "class" value "class"
}
Choose a pool based on URI
switch -glob [string tolower [HTTP::uri]] {
"/clasee*" {
pool class
log local0. "The URL is [HTTP::uri] which is selecting pool class"
}
default {
pool main
log local0. "the URL is [HTTP::uri] which is selecting pool main"
}
}
}
If you are going to v10 then the code would like like the following
when HTTP_REQUEST {
Insert cookie if it matches the CLASS_IP datagroup
if { [class match [IP::client_addr] equals "class_ip" } {
HTTP::cookie insert name "class" value "class"
log local0. "The Source IP: [IP::client_addr] matched. Inserting Cookie"
}
Choose a pool based on URI
if { [HTTP::uri] starts_with "/clasee*"} {
pool class
log local0. "The URL is [HTTP::uri] which is selecting pool class"
} else {
pool main
log local0. "the URL is [HTTP::uri] which is selecting pool main"
}
}
OR Using a switch statement for v10
when HTTP_REQUEST {
Insert cookie if it matches the CLASS_IP datagroup
if { [class match [IP::client_addr] equals "class_ip"] } {
HTTP::cookie insert name "class" value "class"
log local0. "The Source IP: [IP::client_addr] matched. Inserting Cookie"
}
Choose a pool based on URI
switch -glob [string tolower [HTTP::uri]] {
"/clasee*" {
pool class
log local0. "The URL is [HTTP::uri] which is selecting pool class"
}
default {
pool main
log local0. "the URL is [HTTP::uri] which is selecting pool main"
}
}
}
I hope this helps
Bhattman
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects