Forum Discussion

acephalo_330339's avatar
acephalo_330339
Icon for Nimbostratus rankNimbostratus
Aug 13, 2017

Receive original IP throught proxies and LTM or no header at all

Hello,

 

Currently. We are working on on this Irule which keeps all x-forward headers sent by our proxies (You will surely recognize it) :

 

when HTTP_REQUEST { HTTP::header insert HeadTrans [HTTP::header all];

 

if {[HTTP::header exists X-Forwarded-For]}{ HTTP::header replace X-Forwarded-For "[HTTP::header X-Forwarded-For]"; } else { HTTP::header insert X-Forwarded-For [getfield [IP::client_addr] "%" 1]; }

 

Have question about this. If I just want to keep the first action and remove the "else" part... Which mean if the LTM don't found any existing headers I would like to have no header at all. Do I have to have explicit "else { do nothing } or can I only keep my first condition like :

 

when HTTP_REQUEST { HTTP::header insert HeadTrans [HTTP::header all];

 

if {[HTTP::header exists X-Forwarded-For]}{ HTTP::header replace X-Forwarded-For "[HTTP::header X-Forwarded-For]"; }

 

Best regards,

 

Yves

 

2 Replies

  • no you don't need to have an explicit "else { do nothing }" section.

     

  • Hi,

     

    I don't understand the goal of the question. If the header exists, you replace it with the same value, and if the header does not exist, do not insert it... remove the condition will do the same.