Forum Discussion
Dunleap_21354
Nimbostratus
Mar 28, 2008Rewriting HTTP host name
I'm trying to write my first irule. I need to take the client request:
when HTTP_REQUEST {
and replace the HTTP host name H23.abc.com with D2.xyz.com and pass it on to the pool.
HTTP:header replace Location [string map - nocase (H23.abc.com D2.xyz.com) [HTTP::header value Location]]"
I found the above as part of an example. However I'm not sure I understand the meaning of all of the syntax.
Shouldn't there be a value after HTTP:header indicating which part of the header you want and assign it to some type of tag?
[HTTP:header host == ihostname]
or does the string map part just parse through and replace the string match with the second string.
2 Replies
- If you want to replace the host value (http://host/uri), then you won't want the Location header. The Location header is a response header that used for 301 and 302 based redirects. You'll want to use the basic "Host" header. This should work for you.
when HTTP_REQUEST { if { [HTTP::host] equals "H23.abc.com" } { HTTP::header replace "Host" "D2.xyz.com" } }
Or, if you only have the virtual on the H23.abc.com domain, then you can omit the if and just do the assignment.
Unfortunately, there isn't a version of the HTTP::host command that assigns the value so you'll have to do it with the "HTTP::header replace" command.
As for your question about the string map command, your supplied example will replace all values of "H23.abc.com" with "D2.xyz.com" in the HTTP Location response header and assign it to the Location header. Make sense?
-Joe - Dunleap_21354
Nimbostratus
Joe
This does make sense thanks. I was able to creat this rule and get it working as expected. I shall investigate the documentation for what else is available in HTTP::header
Thanks again
David
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
