Forum Discussion
Notanf5engineer
Apr 01, 2023Nimbostratus
Standard irule that can be used for multiple urls
Here is a usecase I have and I am trying to find a solution for it. ABCD.com/app1/anything Translated to: app1.internaldomain.com/everything Abcd.com/app2/api/hello App2.internaldomain.com/API/he...
CA_Valli
Apr 03, 2023MVP
Hello Notanf5engineer
I've built the following bsed on given examples, it might still be incomplete and not cover all of your scenarios but it might be a good starting point
Let me know if I can help you with improving it
Edit: fixed syntax, tested irule
CA
when HTTP_REQUEST {
#If you have multiple SNI that resolve to this VS, consider enabling row below
# if {[string tolower [HTTP::host]] ne "abcd.com"}{ return }
switch -glob [HTTP::uri] {
/app1/* {
# this will match everything starting with /app1/* (case sensitive) , remove "app1" folder and redirect
# ex. /app1/test to /test
# client will see the redirect
set uri [string trimleft [HTTP::uri] /app1]
HTTP::redirect "http://app1.internaldomain.com/$uri"
}
/app2/API/hello {
# this is an exact match on a specific URI (case sensitive)
# URI is not trimmed and is passed as-is
# client will see the redirect
HTTP::redirect "http://api2.internaldomain.com/[HTTP::uri]"
}
default {
# this matches everything not specified before
# HTTP::respond 401
}
}
}
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