Forum Discussion
Policies or iRules for Redirection to at least 2 URLs
I am trying to take 443 traffic and redirect to two different URLs and (probably) 2 different pools.
I don't know if I need (or can have) 2 different VIPs for the same base website name.
I have https://somename.mycompany.com and I need to forward/redirect to https://somename.mycompany.com/site1 AND https://somename.mycompany.com/site1...site1 is not on the same server as site2....it would be separate pools. Would it/should it also be separate VIPs - is that even possible?
Help?
jamie_staplesHow are you making the determination that a request for https://somename.mycompany.com shoud go to /site1 or /site2? Typically what happens is the following.
Client1 requests https://site1.mycompany.com/ then you direct that to the site1 pool.
Client2 requests https://site2.mycompany.com/ then you direct that to the site2 poolIn an ideal world, what you have suggested would have been my preferred solution. It isn't, so I have to "reverse engineer" to get what the application wants. Thank you for your suggestion.
Hello ,
>> I see you want to add a /path , so Try this iRule For redirection :
when HTTP_REQUEST {
if { ([string tolower [HTTP::host]] eq "host1") and ([string tolower [HTTP::uri]] eq "/path1") } {
HTTP::redirect "http://host1/path2"
} elseif { ([string tolower [HTTP::host]] eq "host2") and ([string tolower [HTTP::uri]] eq "/path3") } {
HTTP::redirect "http://host3/path4"
}
}
>> For Pool selection , you can add pool Action selection after each Redirection selection "HTTP::redirect "http://host1/path2" .
Or you can create another iRule for Pool Selection and attach it to the same Virtual server.This looks a lot like my current conundrum...I will test it out and let you know if I have any luck.
Thanks!
Hello, it is possible to resolve multiple URLs on your virtual server IP and perform HTTP-host-based load balancing.
Most common scenario will be https://portal1.mycompany.com and https://portal2.mycompany.com are both resolved with 1.2.3.4 IP address, which is a Virtual Server on F5. These would be two separate websites that need to be load balanced to two different web server farms (pools).
With an HTTP profile (and clientSSL too if it's encrypted), you can retrieve HTTP::host information and use it to send traffic to the appropriate server farm
You can achieve this with an LTM policy (recommended for performance), or with an iRule that looks like this
when HTTP_REQUEST { set host [string tolower [HTTP::host]] switch -glob $host { portal1.mycompany.com { pool PORTAL1 } portal2.mycompany.com { pool PORTAL2 } default { reject } } }
EDIT:: if you instead neet path-based load balancing, you can achieve similar performance by scripting an iRule that retrieves HTTP::uri and performs path-based selection based on its bvalue (in this case, maybe "if" statements perform better thant "switch" statement since "switch" requires exact match while "if" has operators like starts_with or contains that might be more appropriate)
Virtual server configuration will be something like
ltm virtual /Common/multiple_portals_VS { destination 1.2.3.4:443 ip-protocol tcp profiles { /Common/clientssl_wildcard.mycompany.com { context clientside } /Common/serverssl { context serverside } /Common/tcp { } /Common/http { } } rules { /Common/iRule_portal_selection } source 0.0.0.0/0 source-address-translation { pool /Common/sNAT_Pool type snat } translate-address enabled translate-port enabled vlans { /Common/DMZ_External } vlans-enabled }
I wish this were the case...unfortunately, it isn't...but thank you kindly for your detailed suggestion.
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