Forum Discussion
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
Altocumulus
Hi, Thank you for the answer , but i want to natch on HTTP_REQUEST URI or hostname or path.
Once again, can you please provide an example?
Original: http://www.somesite.com/mypath
Transformed: https://www.somesite.com/mynewpath
Seeing is believing, and examples get the point across quickly on what you are trying to accomplish exactly.
- zamroni777
Nacreous
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.htmlTo 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).
- marcoperson_250
Altocumulus
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.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com