Forum Discussion

Gbps_31870's avatar
Gbps_31870
Icon for Nimbostratus rankNimbostratus
Jun 10, 2012

Re-write HTTP host iRule

Hi,

 

 

I would like to know if it is possible to re-write the HTTP host header by F5, and send it to one server. Then, once the server response is received, re-write the HTTP host header again to the original HTTP host value and send it back to the client. Appreciate your help.

 

 

 

5 Replies

  • Richard__Harlan's avatar
    Richard__Harlan
    Historic F5 Account
    Yea it should be no problem

     

     

    when HTTP_REQUEST {

     

    HTTP::header replace Host "newhost.example.com"

     

    }

     

     

    when HTTP_RESPOND {

     

    HTTP::header replace Host "oringal.example.com"

     

    }
  • Thanks Richard for your input ,, I will give it a try and update with the result ,,

     

     

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus
    Gbps / Richard

     

     

    I don't think there's a HTTP_RESPOND event - I doubled checked the Wiki. But, I don't think even using HTTP_RESPONSE would work as there isn't a host header in the response.

     

     

    Hoolio (as always) has answered a similar request here using the stream command:

     

     

    https://devcentral.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/1167408/showtab/groupforums/Default.aspx

     

     

    Hope I'm not mistaken and hope this helps.

     

     

    N
  • Hi Nathan,

     

     

    You're correct. Thanks for linking the other thread with the example. Gbps, if you get stuck with that example reply here with details on the iRule you're testing and what's not working.

     

     

    Aaron
  • Richard__Harlan's avatar
    Richard__Harlan
    Historic F5 Account
    You are right I meant

     

     

    when HTTP_RESPONSE {

     

     

    As for the host header in the response most likely the rewrite would be for the location field if the server is redirecting the client which would rewrite the browser URL. I did not read the question too closely. Though the header replace can be done using the iRUle it could also be done using HTTP classes.