I have a client that has several sites on their server farms. These sites are not separated out and running on different IP’s or ports, but rather use the Apache NameVirtualHost directive. This looks at the URI that the client is requesting, and sends them to the correct site.
Sometimes clients access the site by IP. Requests going to port 80 need to redirect to 443. Additionally, even if the client is using SSL (which terminates on the LTM), the connection made from the LTM to the node is just over port 80. I need to make sure the correct URI is sent to the node when the client connects by typing in an IP only.
What is the best way to go about this?
If I understand you correctly you want the client to be directed to a particular pool or node based on IP addresses. Since you mentioned that there are multiple sites using Apache NameVirtual Hosts, the bigip needs additional information then the IP to determine which node or pool it needs to go to. My guess is you need to inspect the IP address and URI together and redirect them to the correct Host and uri
ie. http://192.168.12.2/site2/something.html ---> http://www.domain.com/site2/something.html
After that Apache will take over and get them to the correct spot.
Hope that helps
CB
I got it. I set up the redirect from HTTP to HTTPS iRule provided in the codeshare on this site. Then on the port 443 VIP, I just used the following iRule. It requires all of the VIPs to be named with the FQDN followed by “-443”. It uses [virtual] to figure out the name of the VIP, strips the -443, and uses that to check against what the client is providing. Works awesome.
when HTTP_REQUEST {
Set our required hostname based on the VIP name
All vips must be named with the FQDN with "-443" appended
set ::myhostname [getfield [virtual name] "-443" 1 ]
log local0. "Virtual Server: $::myhostname"
if { not ( [HTTP::host] equals $::myhostname ) } {
HTTP::redirect "https://$::myhostname[HTTP::uri]"
}
}