Forum Discussion
Syntax to Map Virtual-Server's Character with Data-Group which Contains Pool Name
Kindly have a look into the below Irule:
1.Last part of the Data-Group: dg_parveez_dynamic_pools contains a list of all dynamic pools: 2.Idea is to apply/create a single Irule into the future and attact that into the new Virtual-Servers, and based on that we are planning to add the new dynamic pool into the Data-group created, to make operation task easy and error free. 3. Challenge is: When the user hit the Virtual-server, it should go to the correct Pool which will serve him the request, while matching the name.
when CLIENT_ACCEPTED { set default_pool [LB::server pool] log local0. "Default pool [LB::server pool] set" log local0. "Client IP is [IP::remote_addr]" }
when HTTP_REQUEST {
switch -glob [HTTP::uri] {
"/" {
log local0. "redirecting from /"
HTTP::redirect "http://http://www.lenovo.com/us/en"
return
pool pool_lenovo.com-http
}
"/iss_static*" {
pool $static_pool
return
}
default {
pool [class match -element [string tolower [virtual]] starts_with dg_parveez_dynamic_pools ]
return
}
}
}
- Example of the naming convention of the Virtual-Server and Pool mapped against it is:
a) Virtual-Server: apuat.leni2.com-VS-HTTP , Pool : pool_apuat_leni2.com_http b) Virtual-Server: apbuild.leni2.com-VS-HTTP , Pool : pool_apbuild.leni2.com_http c) Virtual-Server: apctdev.leni2.com-VS-HTTP , Pool : pool_apctdev.leni2.com_http
- Query: By comparing the above Irule, whether the below Irule part will fit our requirement, I mean can the Virtual-server will be intelligent enough to send the traffic to the correct dynamic pool to meet the requirement, or do we need to modify this:
Naming Convention of the Virtual-Server and Pool is mentioned into the Point 04:
default { pool [class match -element [string tolower [virtual]] starts_with dg_parveez_dynamic_pools ] return }
Kindly suggest.
Thanks and Regards Parveez
37 Replies
- Parveez_70209
Nimbostratus
Hi Kevin Sir,
Your reply previously regarding this helped enormously. Heartful thankful to you for understanding the whole requirement, saluting your approach and interest you showed during the whole task.
The below was the Final Irule:( Also attached as an attachment)
========================= when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/" { log local0. "redirecting from /" if { [class match [virtual] equals dg_confarm_pool_routing ] } { HTTP::respond 301 Location [lindex [split [class match -value [virtual] equals dg_confarm_pool_routing] ","] 2] pool [lindex [split [class match -value [virtual] equals dg_confarm_pool_routing ] ","] 0] log local0. "Went to root ( / ), index 0 - WEC pool after index 2 url set with 301" } else { log local0. "Static pool entry for xxxx[LB::server pool] not created yet" reject } return } "/iss_static*" { if { [class match [virtual] equals dg_confarm_pool_routing ] } { pool [lindex [split [class match -value [virtual] equals dg_confarm_pool_routing] ","] 1] log local0. "Went to default, index 1 - Confarm pool" } else { log local0. "Static pool entry for [virtual] not created yet" reject } return }
===========================
where Data-Group: dg_confarm_pool_routing consisting of Virtual-Server name:=Dynamic Pool;Static Pool;URI link.
Now planning to do some more changes into this wr.r.t to accessibily. Means we are planning to restrict the site/URL using somekind of Address Data-group which will contain white-listed IP's.( Only white-listed IP's can reach/browse the Irule). we just needed the new addition into the same Irule.
Thanks and Regards Parveez
- Kevin_Stewart
Employee
I'd wrap the whole thing in another class match for the client IP:
when HTTP_REQUEST { if { [class match [IP::client_addr] equals my_whitelist_dg] } { switch -glob [string tolower [HTTP::uri]] { ... } } else { reject } }
- Parveez_70209
Nimbostratus
Hi Kevin,
Attached is the Irule as per suggestion, getting Syntax error in 2nd line :
Thanks and Regards Parveez
- Kevin_Stewart
Employee
No, I'm talking about wrapping your existing iRule in a client IP evaluation. It's the same iRule with added code. In the last example:
switch -glob [string tolower [HTTP::uri]] { ... }
represents the bulk of your existing iRule.
- Parveez_70209
Nimbostratus
Hi Kevin,
I added the same getting some SYNTAX error:
=========
when HTTP_REQUEST { if { [class match [IP::client_addr] equals my_whitelist_dg] } switch -glob [string tolower [HTTP::uri]] { "/" { log local0. "redirecting from /" if { [class match [virtual] equals dg_confarm_pool_routing ] } { HTTP::respond 301 Location [lindex [split [class match -value [virtual] equals dg_confarm_pool_routing] ","] 2] pool [lindex [split [class match -value [virtual] equals dg_confarm_pool_routing ] ","] 0] log local0. "Went to root ( / ), index 0 - WEC pool after index 2 url set with 301" } else { log local0. "Static pool entry for xxxx[LB::server pool] not created yet" reject } return } "/iss_static*" { if { [class match [virtual] equals dg_confarm_pool_routing ] } { pool [lindex [split [class match -value [virtual] equals dg_confarm_pool_routing] ","] 1] log local0. "Went to default, index 1 - Confarm pool" } else { log local0. "Static pool entry for [virtual] not created yet" reject } return }
Thanks and Regards Parveez
- Kevin_Stewart
Employee
when HTTP_REQUEST { if { [class match [IP::client_addr] equals my_whitelist_dg] } { switch -glob [string tolower [HTTP::uri]] { "/" { log local0. "redirecting from /" if { [class match [virtual] equals dg_confarm_pool_routing ] } { HTTP::respond 301 Location [lindex [split [class match -value [virtual] equals dg_confarm_pool_routing] ","] 2] pool [lindex [split [class match -value [virtual] equals dg_confarm_pool_routing ] ","] 0] log local0. "Went to root ( / ), index 0 - WEC pool after index 2 url set with 301" } else { log local0. "Static pool entry for xxxx[LB::server pool] not created yet" reject } return } "/iss_static*" { if { [class match [virtual] equals dg_confarm_pool_routing ] } { pool [lindex [split [class match -value [virtual] equals dg_confarm_pool_routing] ","] 1] log local0. "Went to default, index 1 - Confarm pool" } else { log local0. "Static pool entry for [virtual] not created yet" reject } return } default { if { [class match [virtual] equals dg_confarm_pool_routing ] } { pool [lindex [split [class match -value [virtual] equals dg_confarm_pool_routing ] ","] 0] log local0. "Went to default, index 0 - WEC pool" } else { log local0. "Dynamic pool entry for [virtual] not created yet" reject } return } } } }
Recent Discussions
Related Content
* 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