Forum Discussion

Amol_Khatavkar_'s avatar
Amol_Khatavkar_
Icon for Nimbostratus rankNimbostratus
Dec 31, 2014

I have SNAT and X-Forwarded-For but this is not working for internal application need to insert WL-Proxy-Client-IP in below iRule please guide.

Below is the existing iRule applied to VIP and want to need to insert WL-Proxy-Client-IP in below iRule

 

ltm rule uri_pool_select { when HTTP_REQUEST { set uri [string tolower [HTTP::uri]] switch -aaaa $uri { /bbbb* - /cccc* { pool wxyz.com } default { pool default.com } } } }

 

iRule for inserting WL-Proxy-Client-IP

 

when HTTP_REQUEST { HTTP::header insert X-Forwarded-For [IP::remote_addr] }

 

please guide on how to combine these two rules?

 

8 Replies

  • please guide on how to combine these two rules?

     

    since their actions do not conflict, you can just combine them (to one HTTP_REQUEST).

     

  • I guess this will work

     

    ltm rule uri_pool_select { when HTTP_REQUEST { HTTP::header insert X-Forwarded-For [IP::remote_addr] and { set uri [string tolower [HTTP::uri]] switch -aaaa $uri { /bbbb* - /cccc* { pool wxyz.com } default { pool default.com } } } }

     

    Please guide me on the above configuration.

     

  • e.g.

    when HTTP_REQUEST { 
      HTTP::header insert X-Forwarded-For [IP::remote_addr] 
    
      set uri [string tolower [HTTP::uri]] 
      switch -glob $uri { 
        /bbbb* - 
        /cccc* { 
          pool wxyz.com 
        } 
        default { 
          pool default.com 
        } 
      } 
    }
    
  • Hi Nitass,

     

    Thanks and for your input.Can you confirm if this will work with AND operator also as below?

     

    ltm rule uri_pool_select { when HTTP_REQUEST { HTTP::header insert X-Forwarded-For [IP::remote_addr] and { set uri [string tolower [HTTP::uri]] switch -aaaa $uri { /bbbb* - /cccc* { pool wxyz.com } default { pool default.com } } } } }

     

    Thank again.

     

  • Hi Nitass,

     

    Thanks for your response.

     

    Can you tell me the difference between below two lines,

     

    HTTP::header insert X-Forwarded-For [IP::remote_addr]

     

    HTTP::header insert WL-Proxy-Client-IP [IP::client_addr]

     

    Thanks again.

     

  • Can you tell me the difference between below two lines

    Returns the IP address of the host on the far end of the connection. In the clientside context, this is the client IP address. In the serverside context this is the node IP address. You can also specify the IP::client_addr and IP::server_addr commands, respectively.
    

    IP::remote_addr

    https://devcentral.f5.com/wiki/iRules.IP__remote_addr.ashx