Forum Discussion
Help with iRule
- Jun 21, 2024
You can negate that second IF as well to avoid the else
when HTTP_REQUEST priority 500 { if { (![class match -- [IP::client_addr] eq "LISTSERV-TST_Allowed_IPs"]) && !(([HTTP::host] eq "lists.example.com") && ([HTTP::uri] matches_glob "/cgi-bin/wa?SUBEDIT1*")) } { HTTP::redirect "https://www.google.com" } }
Or this, rather:
when HTTP_REQUEST priority 500 {
if { ![class match -- [IP::client_addr] eq "LISTSERV-TST_Allowed_IPs"] } {
if { ([HTTP::host] eq "lists.example.com") && ([HTTP::uri] matches_glob "/cgi-bin/wa?SUBEDIT1*") } {
return
} else {
HTTP::redirect "https://www.google.com"
}
}
}
I know we are close, so I am not certain on how to "wrap it up". 😅
You can negate that second IF as well to avoid the else
when HTTP_REQUEST priority 500 {
if { (![class match -- [IP::client_addr] eq "LISTSERV-TST_Allowed_IPs"]) &&
!(([HTTP::host] eq "lists.example.com") && ([HTTP::uri] matches_glob "/cgi-bin/wa?SUBEDIT1*")) } {
HTTP::redirect "https://www.google.com"
}
}
- FastidiousJun 21, 2024Altostratus
Did you miss the ! on `!([HTTP::uri]...`?
- JRahmJun 21, 2024Admin
looks like I just put it in the wrong place! Updated above.
- FastidiousJun 21, 2024Altostratus
JRahmso, this is "working":
when HTTP_REQUEST priority 500 { if { (![class match -- [IP::client_addr] eq "LISTSERV-TST_Allowed_IPs"]) && (([HTTP::host] eq "lists.example.com") && !([HTTP::uri] matches_glob "/cgi-bin/wa?SUBEDIT1*")) } { HTTP::redirect "https://www.google.com" } }
But images are all broken. It is creating a weird CORS/redirect problem
- JRahmJun 21, 2024Admin
might be either a missing use case or the logic is slightly off. If use add the else back in and add return to that block does it fix?
- FastidiousJun 24, 2024Altostratus
I had to account for more, and there are other URIs within the page, and those will be blocked because to not match the glob. So:
when HTTP_REQUEST { if { (![class match -- [IP::client_addr] eq "LISTSERV-TST_Allowed_IPs"]) && (([HTTP::host] eq "lists.example.com") && !([HTTP::uri] matches_glob "/cgi-bin/wa?SUBED1*") && !([HTTP::uri] matches_glob "/archives/images/*")) } { HTTP::redirect "https://www.google.com" } else { return } }
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