04-Oct-2017 13:49
I am trying to do a irule redirect for urls. I am trying to trick something for a DR situation. I have a redirect service that is off campus. So for my DR situation I have a closed off network. I trick the DNS with a dns translation on my firewall and point the three different hosts to the same IP on the F5. I created a VIP on that IP and am trying to write and IRule that will redirect based on the URL you think you came from.
So if I goto the dns redirects me to 1.1.1.1 on my F5 I want to redirect that to which is here one of the urls is vip-joe. I wanted to do an if else rewrite but couldn't get it to work. Tried if { [http::host] contains "darmap"} with a redirect. Really lost and tired. Any help would be greatly appreciated. Thanks Joe
04-Oct-2017 21:33
I also want to verify irule.Please post your irule
05-Oct-2017
06:41
- last edited on
01-Jun-2023
13:54
by
JimmyPackets
I tried three things...
when HTTP_REQUEST {
if { [http::host] contains "*bla*"}{
HTTP::redirect "https://www.bla.com"
} elseif { [HTTP::uri] contains "*zip*"}{
HTTP::redirect "https://www.zip.com"
} elseif { [HTTP::uri] equals "*stuff*"}{
HTTP::redirect "https://stuff.com"
} else { pool PFA_NodePool_All
}
}
SEcond try
when HTTP_REQUEST {
switch -glob [HTTP::path] {
"vip-bla*" {
HTTP::redirect "https://newbla.com"
}
"bla*" {
HTTP::redirect "https://newbla.com"
}
"zip*" {
HTTP::redirect "https://newzip.com"
}
"zip*" {
HTTP::redirect "https://newzip.com"
}
"stuff*" {
HTTP::redirect "https://newstuff.com"
}
default {HTTP::redirect "https://otherstuff.com"}
}
}
Third try...
when HTTP_REQUEST {
switch -glob [HTTP::uri]{
"if { [HTTP::uri]contains"*bla*"}{
HTTP::redirect "https://bla.com"
}
"elseif { [HTTP::uri]contains"*vip-bla*"}{
HTTP::redirect "https://bla.com"
}
"elseif{ [HTTP::uri]contains"*zip*"}{
HTTP::redirect "https://zip.com"
}
else {HTTP::redirect "https://otherstuff.com"}
}
}
At the end I tried to shorten it to see if I could get anything to work, the last one won't build so there is a syntax error. If you couldn't tell already my IRule building starts with devcentral search and try to fit it to what I am doing. Thanks Joe
05-Oct-2017
06:46
- last edited on
01-Jun-2023
13:54
by
JimmyPackets
Just to correct your irules :
First
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "bla"}{
HTTP::redirect "https://www.bla.com"
} elseif { [string tolower [HTTP::uri]] contains "zip"}{
HTTP::redirect "https://www.zip.com"
} elseif { [string tolower [HTTP::uri]] equals "stuff"}{
HTTP::redirect "https://stuff.com"
} else {
pool PFA_NodePool_All
}
}
11-Oct-2022 06:23
Hi,
Can you help me on this to redirect the path:
https://mcconxvip001.ucsfmedicalcenter.org:81/files/ADM/index.html
Run below iRule but not working.
if { [HTTP::uri] equals "/"}
{
HTTP::redirect "https://[HTTP::host]/files/ADM/index.html"
}
}
10-Oct-2017 10:16
Hey guys, Thanks so much for your help. The test ended on Friday and I was off yesterday. Unfortunately it ended before I was able to get this working. I was working on a lot of other problems so this could not be my main focus. But I have a base to start with for next test. I think with logging enabled I would be able to find the problem and resolve it.
Thanks again. Joe