Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

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

0
Rate this Question
Comments on this Question
Comment made 2 months ago by 〖Mo〗^2 122

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

<body xmlns:sys="javascript:Sys"  sys:activate="" xmlns:code="http://schemas.microsoft.com/aspnet/code">
    <form method="post" action="./SWT?realm=http%3a%2f%2fwww.example.com%2f&amp;redirect_uri=%2fexample&amp;deflate=true" id="aspnetForm">
<div class="aspNetHidden">
0

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

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,

0
Comments on this Answer
Comment made 2 months ago by youssef 3588

Just for information, (?!expression) is a negative lookahead; it matches a position where expression doesn't match starting at that position.

0