Forum Discussion
Dave_22257
Oct 25, 2011Nimbostratus
URL Redirect
I need to create an irule to redirect certain URI strings to a specific pool on my F5 device. Sound simple enough but I am having issues writing the irule to match the specific URI's.
The uri's are as follows...
https://xyz.net.au
https://xyz.net.au:8181/webex or
https://xyz.net.au:8443/webex
The iRule I created and is failing is as follows...
when HTTP_REQUEST {
switch -glob [HTTP::host] {
"xyz.net.au {
switch -glob [HTTP::uri] {
":8181/*" { use pool Port_XYZ_8181 }
":8443/*" { use pool Port_XYZ_8443 }
default { use pool Pool_XYZ }
}}}}
When broswing to https://xyz.net.au, the web data is redirect and the web page is displayed. When trying xyz.nbet.au:8181/webex the redirect fails. I suspect the irule does not match the :8181/*
How can I write this irule to meet my needs?
Please help.
5 Replies
Sort By
- Just to update the :8181 and :8443 both fail.
- i understand port number e.g. 8181, 8443 is not in HTTP::uri. it is in HTTP::host.
[root@iris:Active] config b virtual bar list bvirtual bar { translate service enable snat automap pool foo destination 172.28.17.33:any ip protocol tcp rules myrule profiles { http {} tcp {} } } [root@iris:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if {[HTTP::host] contains "xyz.net.au"} { switch [getfield [HTTP::host] ":" 2] { "8181" { log local0. "8181" } "8443" { log local0. "8443" } default { log local0. "default" } } } } } [root@iris:Active] config curl -I http://xyz.net.au/ HTTP/1.1 200 OK Date: Mon, 24 Oct 2011 22:14:17 GMT Server: Apache/2.0.59 (rPath) Last-Modified: Sat, 11 Jun 2011 00:31:47 GMT ETag: "667a-67-cfb682c0" Accept-Ranges: bytes Content-Length: 103 Vary: Accept-Encoding Set-Cookie: testcookie=helloworld Content-Type: text/html; charset=UTF-8 Oct 25 15:04:03 local/tmm info tmm[4672]: Rule myrule : default [root@iris:Active] config [root@iris:Active] config curl -I http://xyz.net.au:8181/ HTTP/1.1 200 OK Date: Mon, 24 Oct 2011 22:14:32 GMT Server: Apache/2.0.59 (rPath) Last-Modified: Sat, 11 Jun 2011 00:31:47 GMT ETag: "667a-67-cfb682c0" Accept-Ranges: bytes Content-Length: 103 Vary: Accept-Encoding Set-Cookie: testcookie=helloworld Content-Type: text/html; charset=UTF-8 Oct 25 15:04:17 local/tmm info tmm[4672]: Rule myrule : 8181 [root@iris:Active] config curl -I http://xyz.net.au:8443/ HTTP/1.1 200 OK Date: Mon, 24 Oct 2011 22:14:45 GMT Server: Apache/2.0.59 (rPath) Last-Modified: Sat, 11 Jun 2011 00:31:47 GMT ETag: "667a-67-cfb682c0" Accept-Ranges: bytes Content-Length: 103 Vary: Accept-Encoding Set-Cookie: testcookie=helloworld Content-Type: text/html; charset=UTF-8 Oct 25 15:04:30 local/tmm info tmm[4672]: Rule myrule : 8443
- understand port number e.g. 8181, 8443 is not in HTTP::uri. it is in HTTP::host.
- Solution privided has been implemented and tested successfully...
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