Forum Discussion

newf5learner_13's avatar
newf5learner_13
Icon for Nimbostratus rankNimbostratus
Jun 19, 2014

irules - reverse proxy with x-forwarder for http

Hi

can someone help to write multiple conditional statements in one if statement. Basically I'm trying to club the reverse proxy iRule for Lync and iRule to insert the original client IP address in an X-Forwarded-For HTTP header. I'm poor in writing irules. can someone help with basics and let me know what is going wrong if I use the following irule.

the requirement : The rule should act as reverse proxy and server should log with the original client Ip address instead of LTM's self IP address as I have SNAT automap enabled.

when HTTP_REQUEST { ([HTTP::header] insert X-Forwarded-For [IP::remote_addr]) and ([HTTP::uri] contains "WebTicket/WebTicketService.svc/Auth") } {

  switch [string tolower [HTTP::host]] { 

tokyo.lync4u.com { pool pool_test_lync13 } } } }

Its throwing me errors, I tried to work. but as I have less knowledge on irules, I want some assistance from you guys.

can someone try to amend the irule for me so that

7 Replies

  • You can enable the insertion of the X-forwarded-for header in the HTTP profile you have applied to your virtual server. Is there a reason you need to do it through an iRule instead of the HTTP profile?

     

    • newf5learner's avatar
      newf5learner
      Icon for Nimbostratus rankNimbostratus
      though I have enabled that in http profile, logging at the server end doesn't give me any information about the client IP addresses, I can only see the LTM self IP addresses.
    • Cory_50405's avatar
      Cory_50405
      Icon for Noctilucent rankNoctilucent
      You can verify it's being inserted by doing a tcpdump on the LTM and digging into the HTTP information being sent to the server.
    • newf5learner's avatar
      newf5learner
      Icon for Nimbostratus rankNimbostratus
      thanks all.. this has been fixed.!! Its a problem on the server.
  • kunjan's avatar
    kunjan
    Icon for Nimbostratus rankNimbostratus

    Have you configured the web server to log "X-forwarded-for" header? Something like this

     

    • newf5learner's avatar
      newf5learner
      Icon for Nimbostratus rankNimbostratus
      thanks all.. this has been fixed.!! Its a problem on the server.