Forum Discussion
irule for F5 to return a message/string
Folks,
i need to do load-balancing based on the "uri" in the url. I have this working BUT need the F5 to return a http code/message like"Use /dev or /qa to go to your environments" if no uri is matched. I don`t need to do a re-direct to another webserver as I do not have one that can send the same message.
Have the folowing irule -
when HTTP_REQUEST {
if {[HTTP::uri] contains "/dev"} {
pool dev-suite-pool
if {[HTTP::uri] contains "/qa"} {
pool qa-suite-pool
} else {
*****test message: please use /dev, or /qa or /uat to go to your respective environments"
}
}
Please advise?
23 Replies
- What_Lies_Bene1
Cirrostratus
OK, does the VS have a HTTP Profile assigned? I'm sure it does.
You may want to try Kevin's version with the commands on new lines. Or perhaps you need to exit the rule asap;when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/dev*" { pool dev-pool return } "/qa*" { pool qa-pool return } "/uat*" { pool uat-pool return } default { HTTP::respond 200 content "Please use /dev to go to the dev-webserivces-proxies, /qa to go to the qa-webserivces-proxies, /uat to go to the uat-webserivces-proxies" noserver Content-Type "text/html" Connection Close } } } - sandy16
Altostratus
I have exactly the above irule now on the vip, this is what i get in the ltm logs :-
just the url-
Nov 10 09:55:19 tmm1 info tmm1[9232]: Rule /Common/new-services : URI = /
with the uris-
Nov 10 09:54:32 tmm info tmm[9231]: Rule /Common/new-services : URI = /qa/
Nov 10 09:54:37 tmm1 info tmm1[9232]: Rule /Common/new-services : URI = /dev
So its seems to be matching the uris, but not taking the right action. - What_Lies_Bene1
Cirrostratus
The logging Kevin suggested won't log the action, just the URI. If you want to log the actions, add something like log local.0 "Selected XXX-pool" before each 'return' command and log local0. "Responded with content" after the HTTP::respond command.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
