Forum Discussion

Albert__Tase_70's avatar
Albert__Tase_70
Icon for Nimbostratus rankNimbostratus
Jan 14, 2008

Catch all

I have a very large irule and currently I need to add the following logic but not sure how too

 

 

I alkimia inserts say x in the http header when stff comes from them I need to be able to catch the requests not coming from them and insert the remote ip address.

 

 

elseif{ HTTP:header contains X do nothing process the rest of the rule if http header dose not contain X inserts X plus remote IPaddress pool X I need to make sure that if X is present in the header I do not add it again

 

 

 

thanks

 

 

 

 

5 Replies

  • Hello Al,

    I'm not sure I follow. Are you wanting to use a rule to insert a new header with the client IP address as the value if the header doesn't already exist in the request?

    If so, you can use something like this:

    
    when HTTP_REQUEST {
        Check if HTTP header X is not present in the request and does not have value
       if {not ([string length [HTTP::header value X])]}{
          HTTP::header insert X [IP::client_addr]
       }
    }

    Aaron
  • almost if http:header dose not have X in the httpheader then insert client ip alkimia inserts x into the http header and we need a way to catch traffic that dose not go through the alkima would be easy if it was just one url but they want all traffic that dose not have x in the header to get the client ip inserted to the http header this will be goign into a massive redirectr rule of elseif statements and need to make sure when I apply it to the rule that if it already has x in the header it just sends traffic on.

     

     

    Thanks

     

     

    Al Tase
  • How about this?

    
    when HTTP_REQUEST {
        Check if HTTP header X does not have an IP address for the value
       if {not ([HTTP::header value X] matches_regex {\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}})}{
           Insert the client IP address in the X header
          HTTP::header insert X [IP::client_addr]
       }
    }

    Aaron
  • elseif { not({HTTP:header XXX_SRC_ADDR) HTTP::header insert XXX_SRC_ADDR [IP::remote_addr])}

     

    pool XXX

     

     

    basically if the HTTP header dose not contain XXX_SRC_ADDR insert XXX_SRC_ADDR [IP::remote_addr])}

     

     

    And continue if it dose do nothing.

     

     

    the XXX _SRC_ADDR is what alkimia inserts plust the ip address of ther remote cllient so if thats there do nothing if XXX _SRC_ADDR is not in the http header indert it and the rempote client IP