Forum Discussion
MW1
Cirrus
May 01, 2013How can I insert the client's IP back to them in a HTTP:RESPOND content
I am sure this must be simple so apoligies if I am missing the obvious here. I have an irule that does some checking on the clients IP and other payload of a post a custom error message back to the u...
nitass
Employee
May 01, 2013Special Cases for Using Braces
You can also use braces to enclose strings, just as you would double quotes, but variables won't expand within them unless a command also inside the braces refers to them. Because of that difference, if you need to handle strings containing $, \, [], (), or other special characters, braces will work where double quotes won't.iRules Optimization 101 - 04 - Delimiters: Braces, Brackets, Quotes and more by Deb Allen
https://devcentral.f5.com/tech-tips/articles/irules-optimization-101-04-delimiters-braces-brackets-quotes-and-more
so, you may try something like this.
e.g.
example1
[root@ve10:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
set data "\r\nYour [IP::client_addr] has not been recognized.\r\n\r\nPlease contact company support.false\r\n"
HTTP::respond 200 content $data noserver "Content-Type" "text/xml; charset=utf-8"
}
}
[root@centos17 ~] curl http://172.28.19.252
Your 172.28.20.17 has not been recognized.
Please contact company support.false
example2
[root@ve10:Active] config b rule myrule list
rule myrule {
when RULE_INIT {
set static::data {
Your IP address has not been recognized.
Please contact company support.false
}
}
when HTTP_REQUEST {
HTTP::respond 200 content [string map [list "IP address" [IP::client_addr]] $static::data] noserver "Content-Type" "text/xml; charset=utf-8"
}
}
[root@centos17 ~] curl http://172.28.19.252
Your 172.28.20.17 has not been recognized.
Please contact company support.false
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