Forum Discussion
Selective pool member based on uri
Hi,
Some of my webservers are not responding and we take them out from pool at times. The task is to have something like:
https://[HTTP::host]/one
select pool member 1 & at the same time it should change the uri from /one to /web/main/page
https://[HTTP::host]/two
select pool member 1 & at the same time it should change the uri from /one to /web/main/page
I tried using find classs as listed below but not very sure hot to select pool member based on uri
set uri [findclass [HTTP::path] mainredirect " "]
if {$line ne ""}{
HTTP::uri $uri
}
mainredirect is a datagroup of string type
"/one /web/main/page"
"/two /web/main/page"
H/W is LTM 1600 running 10.2
Also I am very bad in GUI and this box can only be accessed via GUI, so not very sure whether the class created should be a data group or something else.
Please suggest
12 Replies
- Ajmal_2608
Nimbostratus
Also this is a running website, so whatever code I need to play with should affect only the /one & /two URIs - nitass
Employee
so not very sure whether the class created should be a data group or something else.yes, class is data group (in gui).
e.g.[root@ve10:Active] config b virtual bar443 list virtual bar443 { snat automap pool foo destination 172.28.19.252:443 ip protocol 6 rules myrule profiles { clientssl { clientside } http {} tcp {} } } [root@ve10:Active] config b pool foo list pool foo { members 200.200.200.101:80 {} } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if { [class match -- [string tolower [HTTP::path]] equals mainredirect] } { HTTP::uri [class match -value [string tolower [HTTP::uri]] equals mainredirect] } } } one [root@ve10:Active] config ssldump -Aed -nni 0.0 port 443 or port 80 -k /config/ssl/ssl.key/default.key New TCP connection 1: 172.28.19.251(42778) <-> 172.28.19.252(443) 1 1 1357914860.8571 (0.0478) C>S SSLv2 compatible client hello 1 2 1357914860.8573 (0.0001) S>CV3.1(81) Handshake 1 3 1357914860.8573 (0.0000) S>CV3.1(953) Handshake 1 4 1357914860.8573 (0.0000) S>CV3.1(4) Handshake 1 5 1357914860.8592 (0.0019) C>SV3.1(262) Handshake 1 6 1357914860.8592 (0.0000) C>SV3.1(1) ChangeCipherSpec 1 7 1357914860.8592 (0.0000) C>SV3.1(36) Handshake 1 8 1357914860.8791 (0.0198) S>CV3.1(1) ChangeCipherSpec 1 9 1357914860.8791 (0.0000) S>CV3.1(36) Handshake 1 10 1357914860.8801 (0.0010) C>SV3.1(179) application_data --------------------------------------------------------------- HEAD /one HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: 172.28.19.252 Accept: */* --------------------------------------------------------------- New TCP connection 2: 200.200.200.10(42778) <-> 200.200.200.101(80) 1357914860.8823 (0.0010) C>S --------------------------------------------------------------- HEAD /web/main/page HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: 172.28.19.252 Accept: */* --------------------------------------------------------------- two [root@ve10:Active] config ssldump -Aed -nni 0.0 port 443 or port 80 -k /config/ssl/ssl.key/default.key New TCP connection 1: 172.28.19.251(42780) <-> 172.28.19.252(443) 1 1 1357914942.1202 (0.0179) C>S SSLv2 compatible client hello 1 2 1357914942.1203 (0.0000) S>CV3.1(81) Handshake 1 3 1357914942.1203 (0.0000) S>CV3.1(953) Handshake 1 4 1357914942.1203 (0.0000) S>CV3.1(4) Handshake 1 5 1357914942.1223 (0.0019) C>SV3.1(262) Handshake 1 6 1357914942.1223 (0.0000) C>SV3.1(1) ChangeCipherSpec 1 7 1357914942.1223 (0.0000) C>SV3.1(36) Handshake 1 8 1357914942.1395 (0.0172) S>CV3.1(1) ChangeCipherSpec 1 9 1357914942.1395 (0.0000) S>CV3.1(36) Handshake 1 10 1357914942.1413 (0.0017) C>SV3.1(179) application_data --------------------------------------------------------------- HEAD /two HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: 172.28.19.252 Accept: */* --------------------------------------------------------------- New TCP connection 2: 200.200.200.10(42780) <-> 200.200.200.101(80) 1357914942.1421 (0.0007) C>S --------------------------------------------------------------- HEAD /web/main/page HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: 172.28.19.252 Accept: */* --------------------------------------------------------------- - nitass
Employee
sorry i forgot class/data group.[root@ve10:Active] config b class mainredirect list class mainredirect { { "/one" { "/web/main/page" } "/two" { "/web/main/page" } } } - Ajmal_2608
Nimbostratus
Thanks Nitass
I'll check this and get back - Ajmal_2608
Nimbostratus
Also I wanted to select a specific server/pool member based on /one or /two
How should I do that ? - nitass
Employee
Also I wanted to select a specific server/pool member based on /one or /two you can add "pool xxx member y.y.y.y zzz" command in the irule to select specific pool member.
pool Wiki
https://devcentral.f5.com/wiki/iRules.pool.ashx - Ajmal_2608
Nimbostratus
I am not able to achieve the result
This is HTTP_REQUEST section of my functional/production iRule,Can you help me modifying it so I can achieve following:
URI = /one Converted URI = /web/main/page, Pool member = node1:8180
URI = /two Converted URI = /web/main/page, Pool member = node2:8180Note:
This is a SSL site and The pool which serves the website is the app pool.
==============================================================
when HTTP_REQUEST {
if { [HTTP::header Content-Length] > 0 } then {
set req_length [HTTP::header "Content-Length"]
HTTP::collect $req_length
} else {
set req_length 0
}
if { [HTTP::header "Referer"] ne "" } then {
set referer [HTTP::header "Referer"]
} else {
set referer -
}
Reject unsupported HTTP methods
if { ![matchclass [HTTP::method] equals $::safe_http_methods] } {
set trafficLog "$trafficLog REJECTED:badMethod"
log local0. $trafficLog
HTTP::respond 200 content " Some message here " noserver
}
Before we consider sticky sessions
switch -glob [string tolower [HTTP::uri]] {
"/outage" -
"/maintenance.html" {
HTTP::respond 200 content "" Some message here " noserver
}
"*.exe*" -
"*.dll*" -
"/index.html" -
"/siteasso/" -
"/siteasso/index.html" -
"/jboss.css" -
"/logo.gif" -
"/manager*" -
"/status*" -
"/jmx-console*" -
"/web-console*" -
"/jolokia*" -
"/jbossws*" {
Unauthorized Access Attempted
set trafficLog "$trafficLog REJECTED:secureURI"
log local0. $trafficLog
HTTP::respond 200 content "Some message here" noserver
}
"/" -
"" {
Auto-redirect to main login page
set trafficLog "$trafficLog 302 REDIRECT:mainLogin"
log local0. $trafficLog
HTTP::respond 302 noserver Location "https://[HTTP::host]/Sitea/Web/Main"
HTTP::respond 302 noserver Location "https://[HTTP::host]/maintenance.html"
}
}
Enforce Sticky Sessions
if { [HTTP::cookie "JSESSIONID"] ne "" } {
persist uie [HTTP::cookie "JSESSIONID"] 1920
}
Finally, Loadbalance requests not handled above
switch -glob [string tolower [HTTP::uri]] {
"/gatekeeper*" -
"/scorm_launch*" -
"/aicc_bridge*" -
"/assets*" -
"/siteaasset*" -
"/content*" -
"/crossdomain.xml" -
"/siteacontent*" -
"/sitea_images*" {
use pool learningzone_sitea-content-pool
}
"/*" {
use pool sitea-app-pool-breakdown-testing
}
}
}
- Ajmal_2608
Nimbostratus
The redirect works with following code but for the 1st time I have to enter the URL without /one or /two and once a session is established, the redirection works, however it doesn't help as the traffic goes to a the node to which persistence had been made.
"/one*" {
if {[HTTP::uri] equals {/one}} {HTTP::uri {/Saba/Web/Main/login.html}
use pool yum-app-pool-breakdown-testing member 216.12.159.60 8180
}
}
"/two*" {
if {[HTTP::uri] equals {/two}} {HTTP::uri {/Saba/Web/Main/login.html}
use pool yum-app-pool member 216.12.159.61 8180
}
} - Ajmal_2608
Nimbostratus
The redirect works with following code but for the 1st time I have to enter the URL without /one or /two and once a session is established, the redirection works, however it doesn't help as the traffic goes to a the node to which persistence had been made.
"/one*" {
if {[HTTP::uri] equals {/one}} {HTTP::uri {/Sitea/Web/Main/login.html}
use pool sitea-app-pool-breakdown-testing member 10.12.159.60 8180
}
}
"/two*" {
if {[HTTP::uri] equals {/two}} {HTTP::uri {/Sitea/Web/Main/login.html}
use pool sitea-app-pool member 10.12.159.61 8180
}
} - What_Lies_Bene1
Cirrostratus
Sorry but is this line right? Shouldn't {/one} be "/one" and wouldn't starts_with be better seeing as that's what your switch case it using? Why the two HTTP::uri statements on one line? Why two closing brackets with {/one}}?if {[HTTP::uri] equals {/one}} {HTTP::uri {/Saba/Web/Main/login.html}
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