Forum Discussion

Nath's avatar
Nath
Icon for Cirrostratus rankCirrostratus
May 02, 2017

Modifying http uri response

Hi All, is there any iRules where I can modify the http uri response of the server going to client?

 

The scenario is this, every time the server respond to http request the server includes its hostname to uri.

 

Ex.

 

Now I want to show only to client side. Is this something to do with stream profile?

 

-Nat

 

7 Replies

  • Hello Nat,

     

    Could you please determine which HTTP response header you want to modify ?

     

    Is it in a header or in the body ?

     

    Regards

     

  • P_K's avatar
    P_K
    Icon for Altostratus rankAltostratus

    Did you try replacing the uri in the header under HTTP Response event?

     

  • Nath's avatar
    Nath
    Icon for Cirrostratus rankCirrostratus

    @PK Haven't tried it yet. What I've tried is modifying the http uri response using iRule

     

  • If it is in response headers, you don't need a stream profile for that.

     

    So is it the "Location" header, when your server redirect clients ?

     

    Thanks

     

  • Based on what I understand, you need to replace the "Location" response header.

    In this case please try following irule without the need to add any "Stream" Profile.

    when HTTP_RESPONSE {
    
    if { [HTTP::is_redirect] } {
      if { [HTTP::header Location] contains "/server1" } { 
        log local0. "Location value before replace : [HTTP::header value Location]"
        HTTP::header replace Location [ string map -nocase { "/server1" "" } [HTTP::header value Location] ]
        log local0. "Location value after replace : [HTTP::header value Location]"
         }
       }
       }
    

    You can check the /var/log/ltm to check if it is working well.

    Also replace "/server1" by the name of your backend server.

    Regards