Forum Discussion
Simple "Hello World" iRule
Here's the iRule I tried:
when HTTP_REQUEST {
if { [HTTP::uri] eq "/mytest" } {
set response "Hello World"
HTTP::respond 200 content $response "Content-Type" "text/xml"
}
}
To see if it's working, I've tried the following URLs:
http://[ip]/mytest
https://[ip]/mytest
Neither of the URLs seem to do what I want them to do, which is to simply display "Hello World." Am I doing something wrong, or is my problem in some other configuration in my F5?
Thanks!
- bmw_10782NimbostratusHi Scott,
- Scott_82463Nimbostratusbmw,
Thanks for the quick response!
I changed my iRule to the following:
when HTTP_REQUEST {
if { [HTTP::uri] eq "/mytest" } {
log local0. "Hello World"
HTTP::respond 200 content "Hello World" "Content-Type" "text/xml"
}
}
I added it in with the xui iRule utility, so as far as I know it should be up and running. However, I still don't seem to be getting any response. Does the log local0 line write to /var/log/ltm, or is the default location somewhere else? Also, am I calling the URL correctly to trigger this rule?
Thanks!
- Michael_YatesNimbostratusWorked fine for me:
- Scott_82463NimbostratusI'm starting to think HTTP_REQUEST isn't configured properly on my F5. I just tried the following iRule:
when HTTP_REQUEST {
log local0. "Hello"
}
Nothing is getting written to /var/log/ltm no matter what URL I call. Is there something you have to do to turn an iRule on after you add it to the list? If not, does anyone know why HTTP_REQUEST might not be working?
Thanks!
- hooleylistCirrostratusHi Scott,
when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: Connected to [virtual name] [IP::local_addr]:[TCP::local_port]" HTTP::respond 200 content "Connected to [virtual name] [IP::local_addr]:[TCP::local_port] from [IP::client_addr]:[TCP::client_port]" }
- Scott_82463NimbostratusThe curl command doesn't seem to be working for me, here's what it returned:
* About to connect() to [ip] port 80
* Trying [ip]... Connection refused
* couldn't connect to host
* Closing connection 0
curl: (7) couldn't connect to host
So I'm assuming this means that there's a problem with my F5 rather than my iRules. I'll have to look into this. Thanks for the help everyone!
- hooleylistCirrostratusDo you have ARP enabled on the virtual server address (Local Traffic ›› Virtual Address List)? Is the virtual server enabled?
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