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
Sir, currently I used two-Data groups version( BIGIP V10), one static an done dynaic. As static contents are not coming. I also tired to remove strin tolower too( from the first part), now that's opening:
when HTTP_REQUEST { switch -glob [ HTTP::uri] { "/" { log local0. "redirecting from /" HTTP::redirect "http://www.parveez.com" return pool pool_parveez.com-http } "/iss_static*" { if { [class match [virtual] equals dg_parveez_static_pools] } { pool [lindex [split [class match -value [virtual] equals dg_parveez_static_pools] ","] 1] } else { log local0. "Static pool entry for [virtual] not created yet" reject } return } default { if { [class match [virtual] equals dg_parveez_dynamic_pools] } { pool [lindex [split [class match -value [virtual] equals dg_parveez_dynamic_pools] ","] 0] } else { log local0. "Dynamic pool entry for [virtual] not created yet" reject } return } } }
And Sir also when someone type HTTP, it should redirect to HTTPS.
Thanks and Regards Parveez
- Parveez_70209
Nimbostratus
That'sopening in the sense, test-parveez.com is opening which was not coming earlier and that is redirecting to www.parveez.com/us/en, But when we are browsing
test.parveez.com with the extension used for dynamic contents, in the fiddler seems like /Iss_static contents are failing with 404 error.( something need to change in iss_static part ??)
Thanks and Regards Parveez
- Kevin_Stewart
Employee
I guess I complicated matters by trying to simplify them. The intent was to consolidate the pools into a single data group, so that you didn't have to manage TWO data groups for the same virtual server.
So going back to using TWO data groups, this is what the iRule should look like:
when HTTP_REQUEST { switch -glob [ HTTP::uri] { "/" { log local0. "redirecting from /" HTTP::redirect "https://www.parveez.com" return pool pool_parveez.com-http } "/iss_static*" { if { [class match [virtual] equals dg_parveez_static_pools] } { pool [class match -value [virtual] equals dg_parveez_static_pools] } else { log local0. "Static pool entry for [virtual] not created yet" reject } return } default { if { [class match [virtual] equals dg_parveez_dynamic_pools] } { pool [class match -value [virtual] equals dg_parveez_dynamic_pools] } else { log local0. "Dynamic pool entry for [virtual] not created yet" reject } return } } }
also when someone type HTTP, it should redirect to HTTPS
If all traffic must be HTTPS, then you should put this iRule and pools on an HTTPS VIP, create a separate HTTP (port 80) VIP, and then just apply the built-in "_sys_https_redirect" iRule to that VIP. It will redirect all requests to it to the same HOST/URI on HTTPS.
- Parveez_70209
Nimbostratus
Hi Kevin,
As suggested by you, We created Data-Groups for Static( Parveez_Static104 ) as well as Dynamic(Parveez_Dynamic104) Contents and modified the Irule as below:
For Virtual-servers mentioned below respectively:
a) apuat.leni2.com-VS-HTTP b) apbuild.leni2.com-VS-HTTP c) apctdev.leni2.com-VS-HTTP
a) Virtual-server: apuat.leni2.com-VS-HTTP
Associated Irule as below:
when CLIENT_ACCEPTED { set default_pool [LB::server pool]
b. Virtual-Server : apbuild.leni2.com-VS-HTTP:
Associated Irule as below:
when CLIENT_ACCEPTED { set default_pool [LB::server pool]
c. apctdev.leni2.com-VS-HTTP:
Associated Irule as below:
when CLIENT_ACCEPTED { set default_pool [LB::server pool]
Now the requirement is: incase we can put the ist part of the Irule too into a 3rd Data-group so that when switch-glob for "/" will dynamically select the whole URL amd pool automatically as per the naming convention same as we did for Data-Groups for Static and Dynamic contents For example:
a) In Virtual-server : apuat.leni2.com-VS-HTTP which contains:
"/" as HTTP::redirect "http://apctdev.leni2.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/catalog.workflow:test-home and pool pool_apctdev.leni2.com_http.
a) In Virtual-server : aapbuild.leni2.com-VS-HTTP which contains:
"/" as HTTP::redirect "http://apbuild.leni2.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/catalog.workflow:test-home" and pool pool_apbuild_leni2.com_http.
c) In Virtual-server : apctdev.leni2.com-VS-HTTP which contains:
"/" as HTTP::redirect "http://apctdev.leni2.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/catalog.workflow:test-home" and pool pool_apctdev.leni2.com_http
Kindly suggest.
Thanks and Regards Parveez
- Kevin_Stewart
Employee
There are a few things to note here.
-
First and most important, you cannot issue an HTTP redirect and send traffic to a pool at the same time. A redirect will generate a 302 response to the client to presumably come back to a different URL, and a pool would pass the data through to a server. You would necessarily have to break this into two components such that:
if URI equals "/" redirect to "http://apctdev.leni2.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/catalog.workflow:test-home" if URI equals or starts_with "http://apctdev.leni2.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/catalog.workflow:test-home" send to a pool
-
In my last post I attempted to clear up some confusing by breaking things back into two separate data groups, one for the static and one for the dynamic pools. Prior to that, with both pools in a single data group separated by a comma, you would have used a list command to extract the correct pool member. But if you're now again using separate pools, I'd venture that there's just one per record in each data group and no need to perform any list functions.
-
- Parveez_70209
Nimbostratus
Hi Kevin,
- We checked the status by creating two data-groups: for Static and Dynamic Contents and attach to the Irule and thats works.
- We checked the status by creating One Data-Group too which contain Static and Dynamic Content and it too looking good.
- Now coming back to point no: 1 ,as the part of the new requirement they wanted to create a separate or 3rd Data-group with which bind the full extension with the pool name.
The Aim is to minimize the manual Modification into the Irule.
Now this is the one sample Irule where Static Data-Group is Parveez_Static104 and Dynamic Data-Group named as Parveez_Dynamic104
when CLIENT_ACCEPTED { set default_pool [LB::server pool]
and now as we need to create the 3rd Data-group which will include http://apbuild.leni2.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/catalog.workflow:test-home and pool :pool_apbuild.leni2.com_http and than will need to modify the Irule, so next time we just need to adjust only into the Data-Group.
As you alrready specified some breakup into the Irule with reponse 302, what if we add some 301 redirect in that.
Kindly suggest into this Irule.
Thanks and Regards Parveez
- Parveez_70209
Nimbostratus
Hi Kevin,
Kindly suggest, still waking up just to get some cool advice from you into that :)
Thanks and Regards Parveez
- Parveez_70209
Nimbostratus
Hi Kevin,
Tried modifying few things, kindly suggest whether it will work as per our scenario where currently we are trying to put all in one Common Data-Group as you suggested earlier:
Original Request:
when HTTP_REQUEST { set http_uri [string tolower [HTTP::uri]] log local0. "requested [HTTP::uri]" if {$http_uri equals "/" } { HTTP::redirect "http://ctbuild.leni2.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/catalog.workflow:test-home" pool pool_ctbuild.leni2.com_http
log local0. "redirected from /"
return } elseif { $http_uri starts_with "/iss_static" } {
log local0. "matched /iss_static"
pool pool_confarmct.leni2.com_http
log local0. "pool_confarmct.leni2.com_http defined, [LB::server pool] selected" return
} else {
log local0. "no match for rev. close connection" pool pool_ctbuild.leni2.com_http
}
}
The same has been modified as below:
when HTTP_REQUEST { switch -glob [HTTP::uri] { "/" { log local0. "redirecting from /" if { [class match [virtual] equals Common ] } { HTTP::respond 301 Location [lindex [split [class match -value [virtual] equals Common] ","] 2] pool [lindex [split [class match -value [virtual] equals Common ] ","] 0]
} else { log local0. "Static pool entry for xxxx[LB::server pool] not created yet" reject } return } "/iss_static*" { if { [class match [virtual] equals Common ] } { pool [lindex [split [class match -value [virtual] equals Common] ","] 1] } else { log local0. "Static pool entry for [virtual] not created yet" reject } return } default { if { [class match [virtual] equals Common ] } { pool [lindex [split [class match -value [virtual] equals Common ] ","] 0] } else { log local0. "Dynamic pool entry for [virtual] not created yet" reject } return } }
}
Virtual server name:ctbuild.leni2.com-VS-HTTP
Ist Part URL in Irule: http://ctbuild.leni2.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/catalog.workflow:test-home 2nd Part Static Pool: pool_confarmct.leni2.com_http 3rd Part Static Pool: pool_ctbuild.leni2.com_http
So, Data-Group named Common is configured as :
ctbuild.leni2.com-VS-HTTP:=pool_confarmct.leni2.com_http,pool_ctbuild.leni2.com_http,http://ctbuild.leni2.com/SEUILibrary/controller/e/web/LenovoPortal/en_US/catalog.workflow:test-home
Sincerely looking for your advice into it.
Thanks and Regards Parveez
- Parveez_70209
Nimbostratus
Hi Kevin Sir,
With your constant support and suggestion we modified the Irule and got almost the results, except one last part which is prevailing in 2nd part of the Irule: "/ISS_Static*" , where seems like some /ISS_Static parts are allowing while others are dropping( error 404).
So, seems like 2nd part of the Irule(/ISS_Static) is case-sensitive, so thinking whether we can put something against this which is case-in-sensitive.
So, planning to divide the Irule into three parts by HTTP_REQUEST by replacing the switch -glob syntax:
Sir, how to modify the Final Irule:
===============================================
when HTTP_REQUEST { switch -glob [HTTP::uri] { "/" { log local0. "redirecting from /" if { [class match [virtual] equals Common ] } { HTTP::respond 301 Location [lindex [split [class match -value [virtual] equals Common] ","] 2] pool [lindex [split [class match -value [virtual] equals Common ] ","] 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 Common ] } { pool [lindex [split [class match -value [virtual] equals Common] ","] 1] log local0. "Went to default, index 1 - Confarm pool" } else { log local0. "Static pool entry for [virtual] not created yet" reject } return }
=============================
Kindly suggest Sir.
Thanks and Regards Parveez
- Kevin_Stewart
Employee
Do switch -glob [string tolower [HTTP::uri]] and make sure all of the switch conditions are also lowercase (ie. "/iss_static" vs "/ISS_Static").
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