Forum Discussion

logan92's avatar
logan92
Icon for Altocumulus rankAltocumulus
Dec 14, 2023

how to match hostname,uri & subdomain within stream profile

Hi,

I want to rewrite http contents in webpage based on certain subdomain xxx.yyyy.com , i want only to apply stream profile on this subdomain , the website has many domains like ccc.yyy.com , uuu.yyy.com  , i want to convert some links in webpage from http to https. i've used this solution https://my.f5.com/manage/s/article/K31100432 , it works but it gives us errors in other webpages (other subdomains that exist on same website domain).

 

 

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
      }
}

 

 

How can i match just for certain subdomain or host or uri in stream profile, as i know i need to change response contents from http to https but http response doesn't have URI.

i just need to apply this stream profile for just 1 subdomain exist on this https virtual server.

 

  • You can modify the REGEX experssion. Currently:

     STREAM::expression {@http://@https://@}

    So, if you want to match only on FQDN www.mysite.com, this would be as follows:

     STREAM::expression {@http://www.mysite.com@https://www.mysite.com@}

    Hope this helps? If not, please give examples of the transformation you are looking to accomplish. Initial URI and post URI.

    • logan92's avatar
      logan92
      Icon for Altocumulus rankAltocumulus

      Hi, Thank you for the answer , but i want to natch on HTTP_REQUEST URI or hostname or path.

    • zamroni777's avatar
      zamroni777
      Icon for Nacreous rankNacreous

      as whisperer said that stream directive is regex, so:
       ":" and "." are part of regex syntaxes, so i suggest replace them with \x3A and \x2A
      reference for the hexadecimal codes: https://man7.org/linux/man-pages/man7/ascii.7.html

      To disable server side compression, simply apply HTTP compression profile to the virtual server.
      this enables the compression offload which ltm requests uncompressed response from server (i.e. no Accept-Encoding header in server bound request).

       

  • Hello there,

    First, you use the stream processing language, then you define the matching criteria for each element. Make sure to use precise syntax to accurately capture the desired patterns. You should regularly test your expression in specific cases.

    I hope this is informative for you.