Forum Discussion
URI redirect to different port
Hello,
I have the following scenario where I'm trying to edit the URI on the client side but doesn't exist on the web server.
1 VS with multiple hosts going to there respective pools.
Here is the current iRule config:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"api.site.com" {
switch -glob [string tolower [HTTP::uri]] {
"/xyz/*" {
pool xyz
}
default {
pool default
}
}
}
"api-qa.site.com" {
switch -glob [string tolower [HTTP::uri]] {
"/xyz/*" {
pool xyzqa
}
default {
pool defaultqa
}
}
}
default {
reject
}
}
}
What I need to do is create a URI that gets appended before the actual path to act as a redirect to a different port.
So for example api.site.com/abc/xyz that gets directed to pool abc with the different ports. However the server is still expecting to receive api.site.com/xyz. Everything I've tried I keep getting a 404 error as the internal server doesn't recognize /abc/xyz.
Is it possible to get /abc/xyz to get redirected on the webserver to go to /xyz and keep /abc/xyz as what the user sees in the browser?
1 Reply
- youssef1
Cumulonimbus
Hello
you can try this irule:
when HTTP_REQUEST { HTTP::header insert "SetContextURI" "http://[HTTP::host][HTTP::path]" HTTP::path [string map {/abc/xyz /xyz} [HTTP::path]] STREAM::disable HTTP::header remove "Accept-Encoding" } when HTTP_RESPONSE { STREAM::expression {@/abc/xyz@/xyz@} Enable the stream filter for this response only STREAM::enable re-write Location header HTTP::header replace Location [string map {/abc/xyz /xyz} [HTTP::header Location]] }Don't forget to activate stream profile in your VS.
Let me now if you need help.
Regards,
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
