Forum Discussion
Muhannad
Oct 17, 2022Cirrus
Rewrite Subdomain
Dears, I am wondering about an efficient procedure to search and replace a specific Subdomain in the HOST, What i want to achieve is rewrite the HTTP request toward the server side as follows: Clie...
- Oct 17, 2022
Code above is case sensitive on HTTP::host match.
If you want a case-insensitive match you can run this instead
when HTTP_REQUEST { # log local0. "Client requested host: [HTTP::host]" if { [string tolower [HTTP::host]] starts_with "dir" && [string tolower [HTTP::host]] contains "clust1" }{ HTTP::header replace Host [string map {"clust1" "clust2"}[string tolower [HTTP::host]]] # log local0. "Modified host: [HTTP::host]" } }
Oct 17 15:43:07 bigip info tmm7[11345]: Rule /Common/test-iRule <HTTP_REQUEST>: Client requested host: DIR000.Clust1.Domain.com Oct 17 15:43:07 bigip info tmm7[11345]: Rule /Common/test-iRule <HTTP_REQUEST>: Modified host: dir000.clust2.domain.com
CA_Valli
MVP
Code above is case sensitive on HTTP::host match.
If you want a case-insensitive match you can run this instead
when HTTP_REQUEST {
# log local0. "Client requested host: [HTTP::host]"
if { [string tolower [HTTP::host]] starts_with "dir" && [string tolower [HTTP::host]] contains "clust1" }{
HTTP::header replace Host [string map {"clust1" "clust2"}[string tolower [HTTP::host]]]
# log local0. "Modified host: [HTTP::host]"
}
}
Oct 17 15:43:07 bigip info tmm7[11345]: Rule /Common/test-iRule <HTTP_REQUEST>: Client requested host: DIR000.Clust1.Domain.com
Oct 17 15:43:07 bigip info tmm7[11345]: Rule /Common/test-iRule <HTTP_REQUEST>: Modified host: dir000.clust2.domain.com
Muhannad
Oct 19, 2022Cirrus
This is working perfectly thanks :).
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects