Forum Discussion

_Mo__2's avatar
_Mo__2
Icon for Nimbostratus rankNimbostratus
Dec 13, 2018

Exception in a Stream:expression rewrite in iRule

Hi everyone,

Need your help on how make an exception in the payload of the page when I want to rewrite links from http:// to https://.

I would like to rewrite http://www.example.com in https://www.example.com except 1 link needed for auth on the backend.

The link I don't want to rewrite is:

I added in my iRule the famous irule found here:

when HTTP_REQUEST {
     Disable the stream filter for all requests
    STREAM::disable
     LTM does not uncompress response content, so if the server has compression enabled
     and it cannot be disabled on the server, we can prevent the server from 
     sending a compressed response by removing the compression offerings from the client
    HTTP::header remove "Accept-Encoding"
}

when HTTP_RESPONSE {
 Check if response type is text
 Replace http:// with https://
if {[HTTP::header value Content-Type] contains "text"}{
STREAM::expression {@http://www.example.com@https://www.example.com@ @http%3a%2f%2fwww.example.com@https%3a%2f%2fwww.example.com@}
 Enable the stream filter for this response only
STREAM::enable
}
}

Problem, it rewrote all link but also those for the authentication.

Do you have any idea to make an exception for this link only ?

Thanks a lot.

Mo

2 Replies

  • _Mo__2's avatar
    _Mo__2
    Icon for Nimbostratus rankNimbostratus

    Hum sorry, the link I don't want to rewrite is used with the form:

    
        
    
    
  • Hi,

    can you test this regular expression:

    STREAM::expression {@(?![realm\=])http://www.example.com@https://www.example.com@ @(?![realm\=])http%3a%2f%2fwww.example.com@https%3a%2f%2fwww.example.com@}

    In all case you could achieve you need using regex...

    keep me in touch,