Forum Discussion

F5-Oetti's avatar
F5-Oetti
Icon for Nimbostratus rankNimbostratus
Jan 26, 2018

Question about persistance by checking and if not there inserting HTTP Header Field

Hello,

 

I have ask a question to the experienced experts:

 

I wanted to setup persistance for a service depending on then HTTP Header Field True-Client-IP. So I want to check if the filed is existing and if so that the Persistance is set. On the other hand for the case this field is not set I want to insert the True-Client-IP field and give the remote IP of client to it... So I tried:

 

when HTTP_REQUEST { if { [HTTP::header exists True-Client-IP] } { persist uie [HTTP::header True-Client-IP] } else { HTTP::header insert True-Client-IP [IP::remote_addr] } { persist uie [HTTP::header True-Client-IP] } }

 

I got that error-Message about that....

 

1070151:3: Rule [/Common/Header-Field-True-Client-IP] error: /Common/Header-Field-True-Client-IP:2: error: [undefined procedure: persist uie [HTTP::header True-Client-IP] ][if { [HTTP::header exists True-Client-IP] } { persist uie [HTTP::header True-Client-IP] } else { HTTP::header insert True-Client-IP [IP::remote_addr] } { persist uie [HTTP::header True-Client-IP] }] /Common/Header-Field-True-Client-IP:9: error: [command is not valid in the current scope][}] /Common/Header-Field-True-Client-IP:10: error: [command is not valid in the current scope][}]

 

How can I get this solved?

 

Any good Tip would be highly appreciated.

 

Best Regards Gerhard

 

1 Reply

  • Hello,

    You can try with that one:

    when HTTP_REQUEST {
        set clientip ""
        if { [HTTP::header exists True-Client-IP] } {
            set clientip [HTTP::header True-Client-IP]
        }
        else { 
            HTTP::header insert True-Client-IP [IP::client_addr]
            set clientip [HTTP::header True-Client-IP]
        }
        persist uie $clientip
    }
    

    Regards