Forum Discussion
Need Irule for redirection for port translation
- Apr 10, 2020
Hello Vikash,
Please try below iRule -
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "abc.com" } {
pool abc-pool
}
HTTP::header remove Accept-Encoding
STREAM::disable
}
when HTTP_RESPONSE {
# Disable the stream filter for server responses
STREAM::disable
# Enable the stream filter for text responses only
if {[HTTP::header value Content-Type] contains "text"}{
# Replace 'old_text' with 'new_text'
STREAM::expression {@http://abc.com:8080/@https://abc.com/@}
# Enable the stream filter for this response only
STREAM::enable
}
}
Hope it works for you!
Mayur
Hello ,
Either you can have separate iRule for each host URL and attached all such iRules to the required Virtual Server or
You can add all the URLs under single iRule as given below -
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "abc.com" } {
pool abc-pool
}elseif { [string tolower [HTTP::host]] contains "xyz.com"} {
pool xyz-pool
}
HTTP::header remove Accept-Encoding
STREAM::disable
}
when HTTP_RESPONSE {
# Disable the stream filter for server responses
STREAM::disable
# Enable the stream filter for text responses only
if {[HTTP::header value Content-Type] contains "text"}{
# Replace 'old_text' with 'new_text'
STREAM::expression {@http://abc.com:8080/@https://abc.com/@\
@http://xyz.com:8080/@https://xyz.com/@}
}
# Enable the stream filter for this response only
STREAM::enable
}
I have highlighted additional changes for other url. You can compare both iRules to get clarity. This way you can have multiple re-directions for multiple URLs under same iRule.
Thank you,
Mayur
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