Forum Discussion
HTTP::redirect challenges with Maven requests
Hi,
I am a newbie and am struggling with a problem that is likely very simple so I appreciate your patience with me.
We are trying to configure a rule to redirect https requests from one host to another host with some extra path prepended to it. For example, we want to redirect all requests to machine1.mycompany.com/... to machine2.mycompany.com/content/secure/maven/...
We use an HTTP::redirect statement that basically does this:
when HTTP_REQUEST {
if { [HTTP::host] == "machine1.mycomany.com" } {
HTTP::redirect "https://machine2.mycompany.com/content/secure/maven[HTTP::uri]
}
}
This works fine from a browser but Maven is passing the entire URL including the protocol and hostname in the GET request and what we see coming back from Big IP is the following (Note the Location URL:
HTTP/1.0 301 Moved Permanently
Location: https://machine2.mycompany.com/cont...-1.2.3.pom
Server: BigIP
Connection: close
Content-Length: 0
How can I correct this rule to make it work with Maven that passes the protocol and hostname in the URI?
Thanks for your patience as I learn,
Robert
3 Replies
- rhpatrick_12082
Nimbostratus
Sorry, somehow the location URL got truncated:
Basically, it looks like this:https://machine2.mycompany.com/content/secure/mavenhttps://machine1.mycompany.com/com/mycompany/foo/1.2.3/foo-1.2.3.pom - Kevin_Stewart
Employee
How about something like this:when HTTP_REQUEST { set host "https://machine1.mycompany.com" if { [string tolower [HTTP::uri]] starts_with $host } { Host is in URI set uri [string range [HTTP::uri] [string length $host] end] HTTP::respond 302 Location "https://machine2.mycompany.com$uri" } else { HTTP::redirect "https://machine2.mycompany.com/content/secure/maven[HTTP::uri] } } - rhpatrick_12082
Nimbostratus
Thanks!
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