Forum Discussion
F5 TO LOAD BALANCE TWO DIFFRENT URL'S RUNNING ON THE SAME PORT (URGENT)
Hi Kazeem,
you can host multiple ports (e.g. HTTP:80/HTTPS:443) on a single virtual server. But it will increase the complexity to a great extent (e.g. enabling/disabling SSL and conditinal redirecting if the request was send to TCP:80/TCP:443).
You may take a look to the iRules below to see the differences if you use a single combined Virtual Server in contrast to using two dedicated Virtual Servers.
iRule: Combined HTTP/HTTPS Virtual
when CLIENT_ACCEPTED {
Handle to check the used port
if { [TCP::local_port] == 80 } then {
Handle for HTTP:80 requests (disable SSL profile)
SSL::disable clientside
set is_http 1
} else {
Handle for HTTPS:443 requests (enable SSL profile )
SSL::enable clientside
set is_http 0
}
}
when HTTP_REQUEST {
Handle to apply different rulsets based on the Virtual Portnumber
if { $is_http } then {
Handle for SSL:443 requests
if { [HTTP::host] equals "smartit.networkershome.com" } then {
Handle for request to http://smartit.networkershome.com
HTTP::redirect "https://smartit.networkershome.com/ux/smart-it"
} else {
Handle for request to different HOSTNAMES
}
} else {
Handle for SSL:443 requests
if { [HTTP::host] equals "smartit.networkershome.com" } then {
Handle for request to https://smartit.networkershome.com
if { [HTTP::uri] equals "/" } then {
Handle for request to https://smartit.networkershome.com/
HTTP::redirect "/ux/smart-it"
} else {
Handle for request to https://smartit.networkershome.com/*
}
} else {
Handle for request to different HOSTNAMES
}
}
}
A much easier approach would be to use dedicated Virtual Server for HTTP:80 and HTTP:443 access. In this case each virtual server will have fixed and appropiate SSL settings and have a tailordered iRule / LTM in place to supports the scenario.
iRule: Dedicated HTTP Virtual
when HTTP_REQUEST {
if { [HTTP::host] equals "smartit.networkershome.com" } then {
Handle for request to http://smartit.networkershome.com
HTTP::redirect "https://smartit.networkershome.com/ux/smart-it"
} else {
Handle for request to different HOSTNAMES
}
}
iRule: Dedicated HTTPS Virtual
when HTTP_REQUEST {
if { [HTTP::host] equals "smartit.networkershome.com" } then {
Handle for request to https://smartit.networkershome.com
if { [HTTP::uri] equals "/" } then {
Handle for request to https://smartit.networkershome.com/
HTTP::redirect "/ux/smart-it"
} else {
Handle for request to https://smartit.networkershome.com/*
}
} else {
Handle for request to different HOSTNAMES
}
}
Cheers, Kai
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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
