Forum Discussion
bob_rao_7722
Apr 04, 2006Historic F5 Account
host header
I have a server that is listening as a web server on a virtual host. So when I go to my web browser and type: "images.testme.com" I go to the web site I created on that server. I have two servers set ...
Deb_Allen_18
Apr 11, 2006Historic F5 Account
Let me try to re-state the problem description as I understand it:
1) You have several sites available on 2 or more servers for load balancing. The servers are virtual hosts on the same server answering to the same IP address.
2) The server in your example is configured to serve a virtual site named "images.dev.test.com". (Successful GET uses that Host: header.) Several other virtual hosts are configured on the same IP address. For demonstration purposes, let's say that the other hostnames are "site1.dev.test.com" and "site2.dev.test.com"
3) You'd like users to be able to browse to the various sites by typing "http://images.test.com", "http://site1.test.com", "http://site2.test.com".
4) I'm assuming all these names are pointing to the same virutal server address to which this rule will be applied.
-- straighten me out if I got any of that wrong --
To solve this problem, most customers simply configure the virutal hosts on each webserver with the hostnames the end users will actually use, i.e. "images.test.com". That is the simplest solution, and requires no iRule header translation.
If for some reason the backend hosts /must/ use different hostnames than the BIG-IP virtual server, this rule will translate the inbound host header to that expected by the webserver:
class hostTranslations {
"images.test.com images.dev.test.com"
"site1.test.com site1.dev.test.com"
"site2.test.com site2.dev.test.com"
}
rule hostTranslations_with_lookup {
when HTTP_REQUEST {
set newHost [findclass [HTTP::host] $::hostTranslations " "]
if { [info exists $newHost] } {
HTTP::header replace Host $newHost
}
}
}Or if the naming scheme is consistent enough that you can just always remove the subdomain name, you can use this without having to configure a class:
rule hostTranslations_simpler {
when HTTP_REQUEST {
HTTP::header replace Host [getfield [HTTP::host] "." 1].[getfield [HTTP::host] "." 3].[getfield [HTTP::host] "." 4]
}
}Post a follow up if I didn't get the problem description correct, and I should be able to help further.
/deb
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
