Rewrite http:// to https:// in response content
Problem this snippet solves:
(Maybe I missed it, but) I didn't see a code share for using a
STREAM
profile to rewrite content from http to https.
This share is just to make it easier to find a simple iRule to replace http:// links in page content to https://. It's taken directly from the STREAM::expression Wiki page.
How to use this snippet:
You'll need to assign a STREAM profile to you virtual server in order for this to work (just create an empty stream profile and assign it).
Code :
# Example which replaces http:// with https:// in response content # Prevents server compression in responses 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 if {[HTTP::header value Content-Type] contains "text"}{ # Replace http:// with https:// STREAM::expression {@http://@https://@} # Enable the stream filter for this response only STREAM::enable } }
Tested this on version:
11.5Updated Jun 06, 2023
Version 2.0