For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Former Member's avatar
Former Member
Jun 27, 2017

Conditionally inject text into HTML responses

Hello,

An LTM needs to inspect a server's response pages and rewrite the HTML so that, for every URL written without a specific URI path, the URI path is inserted.

Example:

Server sends back calls to URL

http://server.example
/path
/image.jpeg
-- Ok, no action

Server sends back calls to URL

http://server.example/image.jpeg
-- Need to inject
/path

I haven't been able to get a working syntax, any help will be immensely appreciated.

1 Reply

  • Hi Rodolfo, I had no lucky with regex exclude "(?!path)", so I would to try this way:

    when HTTP_REQUEST {
          STREAM::disable
          HTTP::header remove "Accept-Encoding"
    }
    when HTTP_RESPONSE { 
        if { [HTTP::header value Content-Type] contains "text" } {  
             \w{0,4} = 'path' lenght
            STREAM::expression {@server\.example/\w{0,4}@@}
            STREAM::enable
        }
    }
    when STREAM_MATCHED {
        if { ! ([STREAM::match] ends_with "path") } {
            STREAM::replace [string map {/ /path/} [STREAM::match]]
        }
    }
    

    Regards.