Forum Discussion
Matt_108113
Nimbostratus
Jul 15, 2009Using Irules to mimic apache Virtual hosts
I would like to use I rules to mimic Apache Virtual Hosts.
I have a web server that has a bunch of sites on it and instead of setting up virtual hosts on Apache I wanted to see if I cou...
JRahm
Admin
Jul 17, 2009@bcallahan, yes you could do something like this:
[getfield [domain [HTTP::host] 2] 1]
or
[lindex [split [HTTP::host] .] end-1]
Either of these would take string a string value from HTTP::host of www.site1.com and return only site1
So the rule could be consolidated to:
when HTTP_REQUEST {
HTTP::header replace Host "www.apacheserver.com"
HTTP::uri "/[getfield [domain [HTTP::host] 2] 1][HTTP::uri]
}
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.
HTH...Jason
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