Forum Discussion
marcus_lindner_
Nimbostratus
Jan 11, 2006uri rewrite based on the servername
I am trying to come up with a rule where the server name of the uri is used to rewrite the URL. an example will be:
http://server_1.de/index.html <=> http://server_4.de/server1/index.html
http://server_2.de/index.html <=> http://server_4.de/server2/index.html
http://server_3.de/index.html <=> http://server_4.de/server3/index.html
my first idea... -but is not working
when HTTP_REQUEST {
pool zone_xml_gw
}
when LB_SELECTED {
if { [LB::server addr] equals "server_4.de" } {
set newuri [HTTP::uri "/[HTTP::host][HTTP::uri]"]
HTTP::redirect "http://[HTTP::host]/newuri"
}
else {
node server_1.de 80
node server_2.de 80
node server_3.de 80
}
}
- For redirects based on contents in the URI, you can do it all from within the HTTP_REQUEST event.
when HTTP_REQUEST { set if { [HTTP::host] ends_with "server_1.de" } { HTTP::redirect "http://server_4.de/server1[HTTP::uri]" } elseif { [HTTP::host] ends_with "server_2.de" } { HTTP::redirect "http://server_4.de/server2[HTTP::uri]" } elseif { [HTTP::host] ends_with "server_3.de" } { HTTP::redirect "http://server_4.de/server3[HTTP::uri]" } pool zone_xml_gw }
when HTTP_REQUEST { switch -glob [HTTP::host] { "*server_1.de" { HTTP::redirect "http://server_4.de/server1[HTTP::uri]" } "*server_2.de" { HTTP::redirect "http://server_4.de/server2[HTTP::uri]" } "*server_3.de" { HTTP::redirect "http://server_4.de/server3[HTTP::uri]" } } pool zone_xml_gw }
- Travis_Boyd_906
Nimbostratus
Joe, great information. How would I rewrite the URL before it gets to the client from the server. For example, I have an application that works fine internally. I'm using a proxy server for access from the internet. At one point in the process the application returns a URL to the client using the internal server name (which isn't routable via the internet). Is it possible to rewrite the url before it gets back to the client? I'm able to do basic rewrites via apache as long as the server is routable. Thanks. - The URI isn't returned to the client in the HTTP response.
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