Forum Discussion
3 Replies
- VernonWellsEmployee
Why explicitly identify the server in a redirect, rather than making "abc" resolve to a Virtual Server (which them load balances to the backend servers)? You don't appear to be rewriting any part of the query-uri for the two cases. All other things being equal, that is by far the easiest way to accomplish this.
- titan_101505Nimbostratus
Thank you Vernon,
the is a backend Virtual server , I did a irule to redirect to one of URL, but always redirect one URL, i hope can redirect to 2 URLs with load balance method:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { default { HTTP::redirect "" } } }
Hi Titan,
the iRule below performs a simple round robin redirect to either server1 or server2...
when RULE_INIT { set static::report_nodes "server1 server2" } when HTTP_REQUEST { set random_report_node [lindex $static::report_nodes [expr {int(rand()*[llength $static::report_nodes])}]] HTTP::redirect "http://$random_report_node/Reports_MSSQLSERVER12/Pages/Folder.aspx?ItemPath=%2fReports&ViewMode=List" }
If you want to health-monitor your report servers, so that clients are not getting redirected to offline nodes, then you have to create a pool and some health-monitors for your report servers. The iRule below can then be used to randomly select an available report server...
when RULE_INIT { array set static::report_server_names { "192.168.1.1%1 80" "server1" "192.168.1.2%1 80" "server2" } } when HTTP_REQUEST { if { [active_members POOL_REPORT_SERVERS] > 0 } then { set active_report_nodes [active_members -list POOL_REPORT_SERVERS] set random_report_node [lindex $active_report_nodes [expr {int(rand()*[llength $active_report_nodes])}]] HTTP::redirect "http://$static::report_server_names($random_report_node)/Reports_MSSQLSERVER12/Pages/Folder.aspx?ItemPath=%2fReports&ViewMode=List" } else { HTTP::redirect 200 content "The report server are offline..." } }
Cheers, Kai