Forum Discussion

AhmadJ's avatar
AhmadJ
Icon for Altostratus rankAltostratus
May 25, 2023

f5 mixed contents and block images

Hi

i created HTTPs VS for our website but then i got Mixed content error i solved that issue by applying stream profile and i applied also this irule

when HTTP_REQUEST {
# Disable the stream filter for all requests
STREAM::disable
# LTM does not decompress 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
}
}

but now not all images are loaded through F5 like svg or png

so again i applied

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

when HTTP_RESPONSE {
# Check if response type is text, javascript, svg, or other images
if {[HTTP::header value Content-Type] contains "text" || [HTTP::header value Content-Type] contains "javascript" || [HTTP::header value Content-Type] contains "svg" || [HTTP::header value Content-Type] contains "jpeg" || [HTTP::header value Content-Type] contains "png" || [HTTP::header value Content-Type] contains "gif"} {
# Replace http:// with https://
STREAM::expression {@http://@https://@}
# Enable the stream filter for this response only
STREAM::enable
}
}

but still have issue

Any idea please

9 Replies

  • What are you trying to accomplish? If the origin servers are returning a response with http urls and you want to rewrite to https, you may be better off simply proxying https on the client side of the virtual IP and communicating with the origin (server side) via HTTP.

    Usually, when I do HTTP response rewrites like this, it is when there is an ancient or broken server that uses absolute paths with the inside non routeable IP address as the host. However, in this case, I generally would not filter on the content-type because there would be a few -- lots of elements being loaded by a single HTTP page -- generally text, various images, and perhaps some hosted files like PDFs.

      • Did you look at the web page source to see how the URLs are written? Can you provide an example. In particular, how the image html tag src target is coded from the origin server. Once you have this, one can make a decision based on the issue -- fix on origin server, or have the F5 transform the src reference.

  • Ok, do you know of the origin server is hosting everything -- pages, images, javascript, etc. -- via only HTTP? Or would some elements of the website be mixed - both HTTP and HTTPS?

    If it is all HTTP, then you don't need the IF statement to check for the resource type. However, if there is a mix of resources, then you may have to selectively enable the stream substitution so that the pages are properly retrieved from origin.

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

  • AhmadJ - it looks like you didn't get resolution on your issue? Are you still having problems? Has anything changed, that you can share, to help with troubleshooting?