Forum Discussion
Multiple iRule Redirects, event disable, TCP::close
What is the downside of the following with the TCP::close added?
when HTTP_REQUEST {
if { ([HTTP::uri] equals "/") } {
HTTP::redirect "https://www.mycompany.com/myapproot"
TCP::close
event disable
}
}
Thanks
-Deon
- Michael_YatesNimbostratusHi Deon,
- nitassEmployeeWhat you can do is a "return" to escape the event from further processing.i understand return does not stop processing other event.
[root@iris:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.17.33:http ip protocol tcp rules { myrule myrule2 } profiles { http {} tcp {} } } [root@iris:Active] config b rule myrule list rule myrule { when HTTP_REQUEST priority 100 { if {[HTTP::uri] equals "/"} { HTTP::redirect "http://172.28.17.33/myapproot" TCP::close event disable } log local0. "client [IP::remote_addr]:[TCP::remote_port], uri [HTTP::uri]" } } [root@iris:Active] config b rule myrule2 list rule myrule2 { when HTTP_REQUEST { log local0. "client [IP::remote_addr]:[TCP::remote_port], uri [HTTP::uri]" } } [root@iris:Active] config tail -f /var/log/ltm Oct 15 16:47:58 local/tmm info tmm[4601]: Rule myrule : client 192.168.206.102:62770, uri / since redirect was sent on existing tcp connection, http event was not triggered. [root@iris:Active] config b rule myrule list rule myrule { when HTTP_REQUEST priority 100 { if {[HTTP::uri] equals "/"} { HTTP::redirect "http://172.28.17.33/myapproot" TCP::close event disable } log local0. "client [IP::remote_addr]:[TCP::remote_port], uri [HTTP::uri]" } } [root@iris:Active] config tail -f /var/log/ltm Oct 15 17:09:48 local/tmm info tmm[4601]: Rule myrule : client 192.168.206.102:62848, uri / Oct 15 17:09:48 local/tmm info tmm[4601]: Rule myrule2 : client 192.168.206.102:62848, uri / Oct 15 17:09:48 local/tmm info tmm[4601]: Rule myrule : client 192.168.206.102:62849, uri /myapproot Oct 15 17:09:48 local/tmm info tmm[4601]: Rule myrule2 : client 192.168.206.102:62849, uri /myapproot [root@iris:Active] config b rule myrule list rule myrule { when HTTP_REQUEST priority 100 { if {[HTTP::uri] equals "/"} { HTTP::redirect "http://172.28.17.33/myapproot" TCP::close event disable } log local0. "client [IP::remote_addr]:[TCP::remote_port], uri [HTTP::uri]" } } [root@iris:Active] config tail -f /var/log/ltm Oct 15 17:11:40 local/tmm info tmm[4601]: Rule myrule : client 192.168.206.102:62860, uri / Oct 15 17:11:40 local/tmm info tmm[4601]: Rule myrule : client 192.168.206.102:62861, uri /myapproot Oct 15 17:11:40 local/tmm info tmm[4601]: Rule myrule2 : client 192.168.206.102:62861, uri /myapproot
- DeonNimbostratusHi nitass. Thanks for the assistance. I think your testing scenarios show the TCP::close and the event disable together accomplish what I need. I appreciate your help.
- Magnum_IPNimbostratusIt is a happy day when you find the answer to the exact issue you are having on DevCentral ;-) The solution works like a charm. A thought that did cross my mind was if there was any potential performance hit from creating new tcp connections per request especially on an https virtual server? I will need to lab this up and run a test.
- ArieAltostratus
Another option is to set a semaphore everywhere an iRule uses HTTP::response (HTTP::redirect counts as an HTTP::response). Although not as efficient, it does make it easier to prevent multiple responses - especially if there are multiple iRules and multiple iRule developers.
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