Forum Discussion
Ross_Fitheridge
Nimbostratus
Jul 13, 2007increment pointer in array
I am trying to redirect to one of any hosts, to give some form of basic load balancing, like round robin, otherwise it goes to the default pool.
I guess I need an array and a pointer to incr...
Ross_Fitheridge
Nimbostratus
Jul 16, 2007thanks Joe,
I made it slightly to simple for you. My hostnames, are just random names. The uri, is actually what I am testing on. Not sure if its optimal but it works. I just need to think about how to deal with the remote hosts being off-line.
when RULE_INIT {
list of hosts to redirect to sequentially
set ::HOSTNAME [list \
pluto \
saturn \
]
set number of hosts as in list.
set ::HOST_NUM [llength $::HOSTNAME]
set number of hosts one less than in list, why? list index starts at zero.
incr ::HOST_NUM -1
initialize a global variable with index 0
set ::REDIR_NUM 0
}
when HTTP_REQUEST {
Send to Content only available on Redbus www.acme.de direct to server
Jobs
if { [findstr [string tolower [HTTP::uri] ] "/acmeonline/de/" 15 "/"] equals "jobs.nsf" } {
if global index is greater than hostnum, reset it to zero
if { $::REDIR_NUM > $::HOST_NUM } {
set ::REDIR_NUM 0
}
HTTP::redirect https://[lindex $::HOSTNAME $::REDIR_NUM].rent-at-acme.com[HTTP::uri]
increment the global index
incr ::REDIR_NUM
RetroClaim
} elseif { [findstr [string tolower [HTTP::uri] ] "/acmeonline/" 12 "/"] equals "retroclaim.nsf" } {
if global index is greater than hostnum, reset it to zero
if { $::REDIR_NUM > $::HOST_NUM } {
set ::REDIR_NUM 0
}
HTTP::redirect https://[lindex $::HOSTNAME $::REDIR_NUM].rent-at-acme.com[HTTP::uri]
increment the global index
incr ::REDIR_NUM
Send www.acme.de to the Proxy Cache virtual servers.
} elseif { [HTTP::host] equals "www.acme.de"} {
snat none
pool Cache_Server_Pool
......some additonal conditions................
If there is anything else left then send to default.
}
}
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