syntax error
4 TopicsUndefined Procedure with elseif when using comments
I am having trouble committing the following iRule when adding in comments above the elseif statements. It always interprets the first comment it finds above an elseif statement as the offender. 01070151:3: Rule [/Common/Main_Website_80_Revised] error: /Common/Main_Website_80_Revised:7: error: [undefined procedure: elseif][elseif {[class match [HTTP::host] eq group_80_encrypt]} { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] }] Removing all comments (aside from line 2, that one seems fine) will commit the iRule without any issue. Any idea what might be going on? when HTTP_REQUEST { 302 redirect to a different URL based on hostname if {[class match [HTTP::host] eq group_80_host_redirect]} { HTTP::redirect [class match -value [HTTP::host] eq group_80_host_redirect] } 302 redirect to enforce HTTPS based on hostname or URI elseif {[class match [HTTP::host] eq group_80_encrypt]} { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] } Pool selection based on hostname elseif {[class match [HTTP::host] eq group_80_host_pool]} { pool [class match -value [HTTP::host] eq group_80_host_pool] } Pool selection based on URI elseif {[class match [HTTP::uri] starts_with group_80_uri_pool]} { pool [class match -value [HTTP::uri] starts_with group_80_uri_pool] } else { pool Main_80_Pool } }Solved862Views0likes5CommentsiRule to check URI and Client source IP using data groups
Hi everybody, I'm trying to achieve the following with my iRule: 1. Check for URI and if its /abc/* choose pool_A 2. Check for URI and if its /abc-preprod/* also check if Client's IP is from internal pool using datagroup "internalIP" 3. If both checks under 2 are good, choose pool_b 4. Discard everything else that wasn't caught by 1 or 2 My iRule is: when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/abc/*" { log local0. "Detected [HTTP::uri] URL" pool pool_A log local0. "Production pool selected" } "/abc-preprod/*" { log local0. "Detected [HTTP::uri] URL" if { ([class match [IP::remote_addr] equals $::internalIP]) } log local0. "Client IP [IP::remote_addr] belongs to private network" pool pool_B log local0. "Pre-production pool selected" } default { discard log local0. "Wrong URI or Client connecting to Pre-prod from external, packet discarded" } } } However I'm unable to get the syntax working and it fails with: 01070151:3: Rule [/Common/***_redirect_iRule_Logging] error: /Common/***_redirect_iRule_Logging:8: error: [missing a script after "if"][ ] Can somebody help?500Views0likes4Commentscorrect syntax for boolean expressions
I experiencing errors with forming a simple boolean expression that would be valid in most "C like" languages ( if we added an equals sign = 😞 set var1 $var2 && !$var3 error: [wrong args][set var1 $var2 && !$var3] set var1 ($var2 && !$var3) error: [wrong args][set var1 ($var2 && !$var3)]799Views0likes13Commentsundefined procedure error in iRule
Hello Folks, Could you please help me correcting my following iRule? ================================================================ when CLIENT_ACCEPTED { if { [IP::addr [IP::remote_addr] equals 172.22.64.0/24] } { snat 172.22.64.68 log local0. "SNATTed of SiteB" pool Test_pool } elseif { [IP::addr [IP::remote_addr] equals 2.2.2.0/24] } { snatpool NAME_OF_SNAT_POOL pool Pool_Name log local0. "SNATTed of SiteA" } else { pool Normal } } I am getting following errors while adding it to my F5. "01070151:3: Rule [/Common/Test] error: line 11: [undefined procedure: elseif] [elseif { [IP::addr [IP::remote_addr] equals 2.2.2.0/24] }] line 15: [undefined procedure: snatpool NAME_OF_SNAT_POOL pool Pool_Name log local0. "SNATTed of SiteA" ] [{ snatpool NAME_OF_SNAT_POOL pool Pool_Name log local0. "SNATTed of SiteA" }] line 21: [undefined procedure: else] [else { pool Normal }]" I am newbie to programming, hence I couldn't figure out the syntax error. :( Seek for your help. Thanks, Darshan767Views0likes15Comments