Forum Discussion

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

Re-write HTTP host iRule




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
    Historic F5 Account
    Yea it should be no problem



    when HTTP_REQUEST {


    HTTP::header replace Host ""





    when HTTP_RESPOND {


    HTTP::header replace Host ""


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



  • nathe's avatar
    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:





    Hope I'm not mistaken and hope this helps.



  • 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.



  • Richard__Harlan's avatar
    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.