Forum Discussion

2funky_105078's avatar
Apr 09, 2014
Solved

data group iRule

Hello iExperts, I just wanted to double check with you the following irule where i want to double check that the client IP is in a determinate data group range of IPs (ecmvpn_ip_dg) and if so, retu...
  • IheartF5_45022's avatar
    Apr 09, 2014

    Hi you don't need to use static variables - just use a TCP connection scoped variable set in CLIENT_ACCEPTED. Not too sure what you want from the switch ...anyway updated slightly

    when CLIENT_ACCEPTED {
        set ecmvpn_flag 0
        if { [class match [IP::client_addr] equals ecmvpn_ip_dg] } {
            set ecmvpn_flag 1
        }
    }
    
    when HTTP_REQUEST {
        if {$ecmvpn_flag}{
             You need an FQDN here so I've added ".com.au"
            HTTP::redirect http://ecmvpn.com.au[HTTP::uri]
            return
        }
    
        switch -glob [string tolower [HTTP::host]] {
            "ecm.*"
                {
                    if {[string tolower [HTTP::uri]] starts_with "/application"} {   
                            HTTP::header insert USER-IP  [IP::remote_addr]
                             You could just use an HTTP persistence profile attached to the virtual for this
                            persist cookie insert
                            pool pl_DCTM_ECM_APPLICATION 
                            return
                }
            }
            default { return }
        }
    
    }