0

My irule is;

when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/xxxx"} {
HTTP::redirect https://example.com/yyyy
}
if {[HTTP::uri] starts_with "/zzzz"} {
HTTP::redirect https://example.com/bbbb
}
}

This works as we expect it to. We have a virtual server on https://example.com that has a pool (called say poolA, with a node called nodeA).

What we want to do is modify the exisiting irule so that it not only does a redirect but also changes the pool. I tried the following;

when HTTP_REQUEST {
  if {[HTTP::uri] starts_with "/xxxx"} {
  HTTP::redirect https://example.com/yyyy
  poolB
}
if {[HTTP::uri] starts_with "/zzzz"} {
HTTP::redirect https://example.com/bbbb
poolB
}
}

NodeB in poolB has a webserver on it and is listening on the correct port and has a website that matches the direction URL.

If I go to https://example.com/xxxx in Chrome, I get the following error;

error too many redirects

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
fru93thu
  • 9
  • 1
  • 3

1 Answers1

1

I'd go with a switch in this case. If you are redirecting, you don't need to set the pool because that request won't proceed to a pool member.

when HTTP_REQUEST {
  switch -glob [string tolower [HTTP::uri]] {
    "/xxxx*" { HTTP::redirect https://example.com/yyyy }
    "/zzzz*" { HTTP::redirect https://example.com/bbbb }
    "/yyyy*" -
    "/bbbb*" { pool poolB }
  }
}

We have a lot of great tutorials on DevCentral. Here's the first article in a ten-part series on iRules called The101.

Jason Rahm
  • 670
  • 3
  • 14