Forum Discussion

vsgrajput_18926's avatar
vsgrajput_18926
Icon for Nimbostratus rankNimbostratus
Nov 16, 2015

irule to change host and uri from response

I have created below iRule which is working fine with respect to client request

 

when HTTP_REQUEST { if { ([HTTP::host] == "abcd.client.com") and ([HTTP::uri] == "/") } { HTTP::header replace Host "abcd.supplier.com" HTTP::uri "/server can/respond/to/this/uri" pool Pool_supplier } }

 

but server redirect the request to different host/uri in response which client can see, and which we don't want. we want client to see the initial url on which request was initiated. for ex. client send request on abcd.client.com - F5 change the host header and uri to abcd.supplier.com/server can/respond/to/this/uri - server redirect response to new.supplier.com/new uri. The flow is working fine the only concern is to limit client to see abcd.client.com/uri

 

The F5 version is 11.6 HF6 Please suggest an iRule or other solution to fulfill the requirement

 

4 Replies

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    vsgrajput,

     

    Would the Stream Profile help here? See SOL8115: Overview of the Stream profile

     

    You could create a stream profile and in the Target box type in @abcd.client.com/@abcd.supplier.com/server can/respond/to/this/uri@

     

    Hope this helps,

     

    N

     

  • Hi Nathan, Thanks for the response but I have achieved same from the below irule by changing the host header and uri when HTTP_REQUEST { if { ([HTTP::host] == "abcd.client.com") and ([HTTP::uri] == "/") } { HTTP::header replace Host "abcd.supplier.com" HTTP::uri "/server can/respond/to/this/uri" pool Pool_supplier } }

     

    I think above iRule and suggested stream will do the same thing, the problem is server is redirecting request to different url and uri for eg. new.supplier.com/new uri which client can see.

     

    Shall I try @abcd.supplier.com/server can/respond/to/this/uri@new.supplier.com/new rui@

     

    please suggest !!

     

  • For better understanding when HTTP_REQUEST { if { ([HTTP::host] == "abcd.client.com") and ([HTTP::uri] == "/") } { HTTP::header replace Host "abcd.supplier.com" HTTP::uri "/server can/respond/to/this/uri" pool Pool_isupplier } }

     

    ==========

     

    when HTTP_RESPONSE { if { [HTTP::header] contains "new.supplier.com" } { HTTP::redirect "abcd.client.com" } }

     

    The request portion is working as expected, need to something like this in response.