I have a web application (kronos) that I am currently load-balancing. Due to an ongoing issue with the application iteslf users have to access the app via its public IP address as using a URL will not work.
I am in need of an irule to perform the following:
1) Change the following URL/URI from https://website.com/en to https://1.1.1.1/en
The following is a literal translation of what you described. I’m guessing there are more details as to how the application functions, so this may not completely work, as described:
when HTTP_REQUEST {
replace the Host header
HTTP::header replace Host "1.1.1.1"
select a pool and rewrite URI based on URI switch -glob [string tolower [HTTP::uri]] {
"*/en" {
pool pool_a
HTTP::uri "/wfc/logon"
}
"*/fr" {
pool pool_b
HTTP::uri "/wfc/logon"
}
}
}
This really depends on how the application functions. The iRule will basically change the Host header and URI on ingress. What does the application do when you POST credentials? Does it literally redirect you back to its own IP address?
I believe not as I have auto-map configured on the VIP and I can successfully login with https://1.1.1.1/en which is the external VIP IP.
Just to clarify, (SNAT) auto-map is a routing mechanism. If that wasn’t working you wouldn’t be getting any responses at all from the web server. Your original description stated that the URI “ends in /en”. I’m now assuming that it actually starts with “/en”, so the iRule would be subtly different:
when HTTP_REQUEST {
replace the Host header
HTTP::header replace Host "1.1.1.1"
select a pool and rewrite URI based on URI
switch -glob [string tolower [HTTP::uri]] {
"/en*" {
pool pool_a
HTTP::uri "/wfc/logon"
}
"/fr*" {
pool pool_b
HTTP::uri "/wfc/logon"
}
}
}
In most cases the server reads the Host header in the request. If that holds true here, then you just need to modify the HTTP::header replace Host statement to use the hard coded value. That should sufficiently convince the server that the client is using the correct host name.