Forum Discussion
yves_werniers_1
Nimbostratus
Sep 08, 2009pool selection not working
Hello,
I have an irule attached to a virtual server (with no default pool).
In the rule there are some redirects and a pool selection. The pool selection (first elseif statement) is the problem. If I put something else there (like a redirect), it is executed. But the pool selection isn't, and it falls through to the pool selection at the end of the irule.
Any ideas?
when HTTP_REQUEST {
if {[HTTP::host] == "www.mydomain.be" and [HTTP::uri] equals "/"} {
HTTP::respond 301 Location "http://www.mydomain.eu/be/zz/index.jsp"
}
elseif {[HTTP::host] == "www.mydomain.be"} {
pool mydomain_be_pool
}
elseif {[HTTP::host] == "www.mydomain.nl"} {
HTTP::respond 301 Location "http://www.mydomain.eu/nl/zz/index.jsp"
}
elseif {[HTTP::host] == "www.mydomain.fr"} {
HTTP::respond 301 Location "http://www.mydomain.eu/fr/zz/index.jsp"
}
elseif {[HTTP::host] == "mydomain.fr"} {
HTTP::respond 301 Location "http://www.mydomain.eu/fr/zz/index.jsp"
}
if {[HTTP::host] == "www.mydomain.lu"} {
HTTP::respond 301 Location "http://www.mydomain.eu/lu/zz"
}
elseif {[HTTP::host] == "www.mydomain.eu" and [HTTP::uri] equals "/"} {
HTTP::respond 301 Location "http://www.mydomain.eu/zz/index.html"
}
else {
use pool mydomain_eu_pool
}
}
- The_Bhattman
Nimbostratus
Looking at your logic it appears that that you have the same 2 conditions that match, but only the first will be executed while the second will be ignored For example if someone enters http://www.mydomain.be/ then they will be redirected and and sent to pool mydomain_eu_pool. You need to group them together. . . when HTTP_REQUEST { if {[HTTP::host] == "www.mydomain.be" and [HTTP::uri] equals "/"} { HTTP::respond 301 Location "http://www.mydomain.eu/be/zz/index.jsp" pool mydomain_be_pool } elseif {[HTTP::host] == "www.mydomain.nl"} { HTTP::respond 301 Location "http://www.mydomain.eu/nl/zz/index.jsp" } . . .
when HTTP_REQUEST { if [HTTP::uri] eq "/" } { switch -glob [HTTP::host] { "www.mydomain.be" { HTTP::redirect "http://www.mydomain.eu/be/zz/index.jsp" pool mydomain_be_pool } "www.mydomain.nl" { HTTP::redirect "http://www.mydomain.eu/nl/zz/index.jsp" } "www.mydomain.fr" - "mydomain.fr" { HTTP::redirect "http://www.mydomain.eu/fr/zz/index.jsp" } "www.mydomain.lu" { HTTP::redirect "http://www.mydomain.eu/lu/zz" } "www.mydomain.eu" { HTTP::redirect "http://www.mydomain.eu/zz/index.html" } default { pool mydomain_eu_pool } } } }
- yves_werniers_1
Nimbostratus
Sorry, but it does not work. - The_Bhattman
Nimbostratus
I think the confusion stems from exactly how you want the iRule to behave - yves_werniers_1
Nimbostratus
If I enter http://www.mydomain.be/ I want to be redirected to http://www.mydomain.eu/be/zz/index.js and sent to pool mydomain_eu_pool - The_Bhattman
Nimbostratus
Then I think you need to rewrite it aswhen HTTP_REQUEST { if {([HTTP::host] eq "www.mydomain.be") and ([HTTP::uri] eq "/")} { HTTP::respond 301 Location "http://www.mydomain.eu/be/zz/index.jsp" } elseif {[HTTP::host] == "www.mydomain.be"} { pool mydomain_be_pool return } elseif {[HTTP::host] eq "www.mydomain.nl"} { HTTP::respond 301 Location "http://www.mydomain.eu/nl/zz/index.jsp" } elseif {[HTTP::host] eq "www.mydomain.fr"} { HTTP::respond 301 Location "http://www.mydomain.eu/fr/zz/index.jsp" } elseif {[HTTP::host] eq "mydomain.fr"} { HTTP::respond 301 Location "http://www.mydomain.eu/fr/zz/index.jsp" } if {[HTTP::host] eq "www.mydomain.lu"} { HTTP::respond 301 Location "http://www.mydomain.eu/lu/zz" } elseif {[HTTP::host] eq "www.mydomain.eu" and [HTTP::uri] eq "/"} { HTTP::respond 301 Location "http://www.mydomain.eu/zz/index.html" } else { pool mydomain_eu_pool } }
- yves_werniers_1
Nimbostratus
and how is that different from what I originally posted? - The_Bhattman
Nimbostratus
Modified the iRule to add loggingwhen HTTP_REQUEST { if {([HTTP::host] eq "www.mydomain.be") and ([HTTP::uri] eq "/")} { HTTP::respond 301 Location "http://www.mydomain.eu/be/zz/index.jsp" log local0. "This was reached when the url was http://[HTTP::host][HTTP::uri]" } elseif {[HTTP::host] == "www.mydomain.be"} { pool mydomain_be_pool return log local0. "This was reached when the url was http://[HTTP::host][HTTP::uri]" } elseif {[HTTP::host] eq "www.mydomain.nl"} { HTTP::respond 301 Location "http://www.mydomain.eu/nl/zz/index.jsp" log local0. "This was reached when the url was http://[HTTP::host][HTTP::uri]" } elseif {[HTTP::host] eq "www.mydomain.fr"} { HTTP::respond 301 Location "http://www.mydomain.eu/fr/zz/index.jsp" log local0. "This was reached when the url was http://[HTTP::host][HTTP::uri]" } elseif {[HTTP::host] eq "mydomain.fr"} { HTTP::respond 301 Location "http://www.mydomain.eu/fr/zz/index.jsp" log local0. "This was reached when the url was http://[HTTP::host][HTTP::uri]" } if {[HTTP::host] eq "www.mydomain.lu"} { HTTP::respond 301 Location "http://www.mydomain.eu/lu/zz" log local0. "This was reached when the url was http://[HTTP::host][HTTP::uri]" } elseif {[HTTP::host] eq "www.mydomain.eu" and [HTTP::uri] eq "/"} { HTTP::respond 301 Location "http://www.mydomain.eu/zz/index.html" log local0. "This was reached when the url was http://[HTTP::host][HTTP::uri]" } else { pool mydomain_eu_pool log local0. "This was reached when the url was http://[HTTP::host][HTTP::uri]" } }
- The_Bhattman
Nimbostratus
Hi Yves,when HTTP_REQUEST { if { [HTTP::host] eq "www.mydomain.eu" } { switch -glob [HTTP::uri] { "/" { HTTP::respond 301 Location "http://www.mydomain.eu/zz/index.html"} default { pool mydomain_eu_pool} } } if { [HTTP::host] eq "www.mydomain.be" } { switch -glob [HTTP::uri] { "/" { HTTP::respond 301 Location "http://www.mydomain.eu/be/zz/index.jsp" } default { pool mydomain_be_pool } } } switch -glob [HTTP::host] { "www.mydomain.nl" { HTTP::respond 301 Location "http://www.mydomain.eu/nl/zz/index.jsp"} "www.mydomain.fr" - "mydomain.fr" { HTTP::respond 301 Location "http://www.mydomain.eu/fr/zz/index.jsp } "www.mydomain.lu" { HTTP::respond 301 Location "http://www.mydomain.eu/lu/zz" } } }
- Colin_Walker_12Historic F5 AccountVery nice work, cmbhatt! 😄
when HTTP_REQUEST { switch [HTTP::host] { "www.mydomain.eu" { switch [HTTP::uri] { "/" { HTTP::respond 301 Location "http://www.mydomain.eu/zz/index.html" } default { pool mydomain_eu_pool} } } "www.mydomain.be" { switch [HTTP::uri] { "/" { HTTP::respond 301 Location "http://www.mydomain.eu/be/zz/index.jsp" } default { pool mydomain_be_pool } } } "www.mydomain.nl" { HTTP::respond 301 Location "http://www.mydomain.eu/nl/zz/index.jsp" } "www.mydomain.fr" - "mydomain.fr" { HTTP::respond 301 Location "http://www.mydomain.eu/fr/zz/index.jsp } "www.mydomain.lu" { HTTP::respond 301 Location "http://www.mydomain.eu/lu/zz" } } }
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