Forum Discussion
Kamila_124825
Nimbostratus
May 29, 2013Redirect to host port
Hi,
I want to create iRule with redirection. Something like this -> Pool under dns name mysite.com:80 should route members HOST:8080/test/
is the iRule like this will work?? ->
when H...
Kevin_Stewart
Employee
May 29, 2013If you physically redirect the user to port 8080 you'll need a VIP that's listening on port 8080. If that's NOT what you want (you have a port 80 VIP and pool members listening on port 8080), and you just want to change the Host header to reflect this (internal) port and also change the URI, then something like this might work:
when HTTP_REQUEST {
if { not ( [string tolower [HTTP::uri]] starts_with "/test" ) } {
HTTP::redirect "http://[HTTP::host]/test[HTTP::uri]"
} else {
HTTP::header replace Host "[HTTP::host]:8080"
}
}
The above physically redirects the user (via 302) to "/test" if the original URI doesn't start with the "/test". It also adds the requested URI to the end of the path (ex. /myrequest = /test/myrequest). Not sure if you needed that part. The Host header is then replaced with the same Host header plus the ":8080" port (ex. mysite.com = mysite.com:8080). I'm assuming that since port 80 is the default for HTTP, the user request won't actually contain ":80".
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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