Forum Discussion

Rizky125's avatar
Rizky125
Icon for Nimbostratus rankNimbostratus
Nov 27, 2023

Replace host & aliases URL

hello, We have development with the application for requirement the format, example the application url :

- mysite.com/apps/asset/post ---> it's want like access ----> backsite.com/migration/asset/post

- mysite.com/apps/dss/front ---> it's want like access ----> backsite.com/migration/dss/front

- mysite.com/apps/script/css---> it's want like access ----> backsite.com/migration/script/css

we now create irules :

when HTTP_REQUEST {
if {[string tolower [HTTP::uri]] starts_with "/apps"} {
HTTP::header replace Host "backsite.com"
set removeContent [string map [list "/apps/" "" ] [HTTP::uri]]
HTTP::uri /$removeContent
pool Pool_backsite_apps
}
elseif {[string tolower [HTTP::uri]] starts_with "/apps2"} {
HTTP::header replace Host "backsite2.com"
set removeContent [string map [list "/apps2/" "" ] [HTTP::uri]]
HTTP::uri /$removeContent
pool Pool_backsite2_apps
else {
HTTP::header replace Host "apikey-external-apicast-production.apim-dev.apps.ocp-jkt.backsite.com"
}
}

with this irules the access using HTTP HOST : mysite.com is working to backsite.com with :

mysite.com/apps/migration/asset/post.......

mysite.com/apps/migration/dss/front/.......

mysite.com/apps/migration/script/css/.....

what must to set irules to goals HTTP URI /apps can be aliases /migration , because /apps it differentiator for other path on the apps. we trying to create redirect /apps/migration and removeContent before i replace HTTP:host but not worked