Forum Discussion
edward_snajder_
Aug 18, 2007Nimbostratus
Multiple domains to single IP
I am pointing multiple domains to a single IP on the F5. Say I have
domaina.com
domainb.com
domainc.com
and they are all pointing to 10.1.1.1 in DNS. I have an irule that will...
hooleylist
Aug 20, 2007Cirrostratus
Hi,
One thing to be aware of with using the same IP address and port for multiple domains is that you can't use HTTPS. Only one SSL certificate can be configured per virtual server.
Using your existing logic, you could redirect only if the URI doesn't start with /domaina, /domainb, or /domainc.
If you're redirecting, make sure to include the leading forward slash in the URI:
This:
HTTP::redirect http://[HTTP::host]domainA[HTTP:uri]
Should be this:
HTTP::redirect http://[HTTP::host]/domainA[HTTP::uri]
Here is an example using switch:
when HTTP_REQUEST {
set the host to lowercase and check the domain
switch [string tolower [domain [HTTP::host] 2]] {
domaina.com {
is the parsed domain domaina.com?
if the URI doesn't start with /domainA, redirect the client and prepend /domainA to the URI
if { not ([HTTP::path] starts_with "/domainA/")}{
HTTP::redirect http://[HTTP::host]/domainA[HTTP::uri]
}
stop processing the rule as we have a match
return
}
domainb.com {
if { not ([HTTP::path] starts_with "/domainB/")}{
HTTP::redirect http://[HTTP::host]/domainB[HTTP::uri]
}
return
}
domainc.com {
if { not ([HTTP::path] starts_with "/domainC/")}{
HTTP::redirect http://[HTTP::host]/domainC[HTTP::uri]
}
return
}
default {
take some default action
}
}
}
If you had a lot of domains to handle, it might be easier to maintain if you created a datagroup (class) containing the domains. You could then use the findclass command to search for the requested host in the class and perform the redirect. There is an approximate example in the Codeshare section (Click here).
Hope this gets you started...
Aaron
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