Yep, that’s doable. Do you have a requirement of the name (ie. webserver1), or do you want to redirect even if it’s something like just-trying.domain.com/SITE1? Also, does the case of the SITE1 matter? Do you have specific sites in mind, or will the site always be the first word in the path?
So this Virtual server on the F5 is a one to one ratio so I am not load balancing or anything so I don’t need the webserver name as a requirement, so if they hit.
don’t need to keep the webserver name, and any site that is setup on this host should redirect and if they enter something that is not there I am good with it just being non-existent as this is a backend server that 95% of the time gets queried by redirects from other sites and not direct from users on the internet.
I’m guessing you don’t want to redirect the client. If you did, the client would see the change, try to resolve www.apacheserver.com to an IP address and then make a new request to that IP. To rewrite the host header and URI you could use an iRule like this:
when HTTP_REQUEST {
log local0. "[IP::client_addr][TCP::client_port]: New request to [HTTP::host][HTTP::uri]"
switch [string tolower [HTTP::host]] {
"www.site1.com" {
Rewrite host to www.apacheserver.com
HTTP::header replace Host "www.apacheserver.com"
Prepend /site1 to the URI
HTTP::uri "/site1[HTTP::uri]"
}
"www.site2.com" {
Rewrite host to www.apacheserver.com
HTTP::header replace Host "www.apacheserver.com"
Prepend /site2 to the URI
HTTP::uri "/site2[HTTP::uri]"
}
"www.site3.com" {
Rewrite host to www.apacheserver.com
HTTP::header replace Host "www.apacheserver.com"
Prepend /site3 to the URI
HTTP::uri "/site3[HTTP::uri]"
}
default {
Take some default action?
}
}
}
when HTTP_REQUEST priority 501 {
This event is added for debug only. It bypassed the variable caching for HTTP::host and HTTP::uri
log local0. "[IP::client_addr][TCP::client_port]: Updated request to [HTTP::host][HTTP::uri]"
}
If the application uses absolute references to www.apacheserver.com in response headers and/or content you could rewrite them using ‘HTTP::header replace’ and/or a stream profile and STREAM::expression based iRule, respectively.
With this approach, you might build a class of acceptable websites to compare against to keep noise from hitting your servers. Same principle as Hoolio suggested with the default case in the switch.