Forum Discussion
DarkSideOfTheQ_
Nimbostratus
Jan 23, 2009irule to return status code
I'm still learning here, so bear with me. I am trying to write an irule that will catch requests trying to pull content from a specific set of hosts (ex. myserver1.domain.com, myserver2.domain.com, myserver3.domain.com) and return a 200 status code.
Here is what I have put together, but I'm not sure what I have wrong.
when HTTP_REQUEST {
if { [HTTP::uri]} contains 'myserver' [HTTP::respond 200]
}
TIA,
DarkSide
4 Replies
- dennypayne
Employee
Hi,
You'd want to use HTTP::host rather than HTTP::uri in this case, since myserver is part of the hostname and not the uri. This also assumes that those hostnames all point to the same virtual server address in DNS. Is that what you are looking for?
Also, just responding with a 200 and no content probably won't yield much, but maybe that's what you want.
Denny - Colin_Walker_12Historic F5 AccountDenny's right, so what you'd want instead is something like:
when HTTP_REQUEST { switch -glob [HTTP::host] { "*myserver1.domain.com" - "*myserver2.domain.com" - "*myserver3.domain.com" { HTTP::respond 200 content "Response from LTM iRule" } } }
Of course you can get a lot more detailed in the response you want to send, too. Take a look at the HTTP::respond wiki page for some examples - Click here
HTH,
Colin - DarkSideOfTheQ_
Nimbostratus
You guys are awesome, thanks a bunch. Course, now I've realized I was totally off-base with what I had put together. Is there a good link (maybe the wiki one you provided Colin) that will help me learn the irule syntax that is available in these devices? I know it's TCL based (which I don't know and must learn now), but read that not all TCL commands are implemented.
Colin - Yes, they are all pointing to the same vip, which was serving up some sort of content. The app owner is decommissioning the app and wanted the LB to simply return a 200 status to any 3rd parties were still pointing to it.
Thanks Again,
-DarkSide - DarkSideOfTheQ_
Nimbostratus
nm...if i had bothered to look at the "Spotlight Wikis" links, I would have found what I seek.
Again...Thanks!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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