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