Forum Discussion
Reason for iRule Execution Error
Hi
Multiple URLs are pointing to the same Virtual Server IP but persistence of 600 secs is needed only for a few of them.
Configured the below iRule and applied to the VS but got an Execution error.
===================
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] equals "access.testxyz45.com" or "abc.testxyz45.com" or "def.testxyz45.com" or "mail.testxyz45.com" } {
persist source_addr [IP::client_addr] 600
} else { }
}
=============
Could you please help as i am unable to figure out the error.
Thanks,
Yugandhar.
- JG
Cumulonimbus
What is the error message?
- Yugandhar
Nimbostratus
err tmm5[17765]: 01230140:3: RST sent from 10.16.240.15:443 to 192.168.25.56:49366, [0x2684cbf:1410] iRule execution error
- Lee_Sutcliffe
Nacreous
You if statement is wrong, please try using this iRule, I've used a switch statement as it is less cluttered than several 'or' statements.
when HTTP_REQUEST { switch -glob -[string tolower [HTTP::host]] { "access.testxyz45.com" - "abc.testxyz45.com" - "def.testxyz45.com" - "mail.testxyz45.com" { persist source_addr [IP::client_addr] 255.255.255.255 600 } } }
- youssef1
Cumulonimbus
Hi Yugandhar.
You have a syntax problem. your condition need to be explicit for each value.
you can't set one condition with multiple value. look what you should have done:
if { [string tolower [HTTP::host]] equals "access.testxyz45.com" or [string tolower [HTTP::host]] equals equals "abc.testxyz45.com" or [string tolower [HTTP::host]] equals "def.testxyz45.com" or [string tolower [HTTP::host]] equals "mail.testxyz45.com" } { persist source_addr [IP::client_addr] 600 } else { }
By the way you have to optimise your irule by set your host variable:
set host [string tolower [HTTP::host]] if { $host == "access.testxyz45.com" || $host == "abc.testxyz45.com" || $host == "def.testxyz45.com" || $host == "mail.testxyz45.com" } { persist source_addr [IP::client_addr] 600 } else { }
and finally you have to optimize his irula for his execution as shown by lee:
when HTTP_REQUEST { set host [string tolower [HTTP::host]] switch -glob $host { "access.testxyz45.com" - "abc.testxyz45.com" - "def.testxyz45.com" - "mail.testxyz45.com" { persist source_addr [IP::client_addr] } } }
- JG
Cumulonimbus
Try this one to see if there is a difference:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals ( "access.testxyz45.com" or "abc.testxyz45.com" or "def.testxyz45.com" or "mail.testxyz45.com" ) } { persist source_addr [IP::client_addr] 600 } }
- Samir_Jha_52506
Noctilucent
Will go bit different way to solve issue. It will be easy to add more url in datagroup
. Lets try and update if working.class
class host_url { access.testxyz45.com abc.testxyz45.com def.testxyz45.com mail.testxyz45.com } when HTTP_REQUEST { if { [matchclass [string tolower [HTTP::host]] equals host_url] } { persist source_addr 255.255.255.255 600 persist source_addr [] [] -- DevCentral Syntax Link : https://devcentral.f5.com/wiki/iRules.persist.ashx } }
I will request user to click iRule which working and solving issue. So that other can be refer.
- Yugandhar
Nimbostratus
Hi F5_Rock,
Thank you for providing the iRule, Can we use a Switch Statement instead of an If stmt.
===========
class host_url {
access.testxyz45.com abc.testxyz45.com def.testxyz45.com mail.testxyz45.com }
when HTTP_REQUEST {
switch -glob -[string tolower [HTTP::host]] { host_url { persist source_addr 255.255.255.255 600 } }
}
Thanks,
Yugandhar.
- Samir_Jha_52506
Noctilucent
Syntax is different for switch statement. @youssef has already provided switch iRule. Refer his iRule n let us know if any issue.
- Yugandhar
Nimbostratus
Thank you .. I thought 'host_url' will be replaced with the values specified in the Data Group...So we can't refer a Data Group in the Switch Statement :)
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