Forum Discussion
atoth
Cirrus
May 01, 2015Writing and Rewriting a URI
I've got a vip similar to the below.
when HTTP_REQUEST {`
switch -glob [HTTP::path] {
"/a/b/c" -
"/blah/blah/blah" {
HTTP::header replace "Host" "internal.domain.com"
pool redirect-pool
snat aut...
atoth
Cirrus
May 04, 2015After brainstorming with some coworkers, we came up with this.
when HTTP_REQUEST {
set uri_redirect 0
switch -glob [HTTP::path] {
"/blah/blah/blah*" {
set uri_redirect 1
HTTP::header replace "Host" "external.domain.com"
HTTP::redirect "https:// [getfield [HTTP::host] ":" 1][string map {/blah/blah/blah /a/b/c } [HTTP::path]]"
pool redirect-pool
snat automap
} "/a/b/c*" {
set uri_redirect 0
HTTP::header replace "Host" "external.domain.com"
pool redirect-pool
snat automap
} default { pool default-pool }
}
}
when HTTP_RESPONSE {
if { [HTTP::is_redirect] } {
if { $uri_redirect == 1 } { HTTP::header replace "Host" "internal.domain.com"
HTTP::redirect "https:// [getfield [HTTP::host] ":" 1 ][string map { /a/b/c /blah/blah/blah } [HTTP::path]]"
} else {
HTTP::header replace "Host" "internal.domain.com"
}
}
}
However, after trying it out in the editor and fixing a bunch of errors, I still get
line 21: [command is not valid in current event context (HTTP_RESPONSE)] [HTTP::host]
line 21: [command is not valid in current event context (HTTP_RESPONSE)] [HTTP::path]
Anyone know of a way of rewriting the URI without resorting to using [HTTP::host] or [HTTP::path] ?
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