Forum Discussion

Collums's avatar
Collums
Icon for Nimbostratus rankNimbostratus
May 07, 2018

How to rewrite absolute URL link in http response

We are transitioning to a new set of internal web servers that will be displaying a new website, moving from Cold Fusion to ASP.NET. The old web servers work perfectly with the current SSL offloading configuration in LTM but the new ones cause Chrome to throw up insecure content errors. I am using the irule shown down below to, 1. redirect testing machines to the pool containing the new servers, 2. rewrite server responses that contain http:// with https://.

 

I am referencing this page, https://devcentral.f5.com/codeshare/https-offload-rewriting, for the STREAM rewrite and have the default STREAM profile and a custom HTTP profile attached to the HTTPS VS as well as an HTTP VS running the built-in sys_https_redirect irule. Unfortunately, I am still getting the insecure content errors and the vendor brought in to code the website seems as puzzled as me. So my question is, can LTM rewrite HTML code such as "http://"; to "https://"; ?

 

Here is my irule:

 

when CLIENT_ACCEPTED { if { [class match [IP::client_addr] equals WebTestIPs] } { pool New_WWW_Pool } }

 

when HTTP_REQUEST { Disable the stream filter for client requests STREAM::disable }

 

when HTTP_RESPONSE { Disable the stream filter for server responses STREAM::disable Check if response type is text if { [HTTP::header value Content-Type] contains "text" } { Replace http:// with https:// STREAM::expression {@@} Enable the stream filter for this response only STREAM::enable } }

 

1 Reply

  • You should use the Developer tools in the browser (F12) to see what is not being converted to https references. Some of the "; references may be in files that do not have a "text" content-type.

    I've also seen webservers return references like

    http:\u002f\u002f

    Finally, I usually recommend that you stream replace entire domain references, but that is up to you.

    STREAM::expression {@http://mydomain.com/@https://mydomain.com/@ @http:\u002f\u002fmydomain.com/@https:\u002f\u002fmydomain.com/@}
    

    YMMV