We are looking to send SSL (port 443) traffic to different pools based upon host header. and either un-encrypt or re-encrypt based upon pool used. I have not found any solution after digging through the forums.
Basically we are looking to send 443 traffic to a pool pointing to a different data center (re-encrypted via SSLServer profile) if it does not match a certain host header. If the host header is matched, it needs to send it unencrypted to a local pool (local web servers).
Is there anyway to do this via iRule? From what I’ve read I’m not sure that it is possible so we came up with another hair-brained scheme to have 3 virtual servers. The first will un-encrypt (client SSL) and the pool would point to the second Virtual server. The second virtual server would re-encrypt (server SSL) and have an iRule which would look at the host header. If the host header did not match it would send the traffic to the other datacenter and if it did match send to the third Virtual server. The third virtual server would simply un-encrypt (client SSL) and send to the internal web servers.
Does this sound feasible? I have tested and the BigIP seems to have a problem connecting back to itself (pool pointing to another Virtual Server). I have tried this doing just port 80 traffic and it doesn’t seem to work. My guess is that it is having a problem with NAT/SNAT tables. Any suggestions?
You can certainly inspect the host header and act on the value once you’ve decrypted the request.
The only issue you may encounter is that there can only be a single cert applied to the port 443 virtual server, so HTTPS requests to 1 of the 2 hostnames in question would result in the “cert mismatch” error. Really no way around that one, and the same thing would happen with your proposed workaround (possible in LTM v9.4, which introduced the ability to have a virtual use another virtual as a destination.)
But to use an iRule on a single virtual instead, this should get you on your way:
when HTTP_REQUEST {
set reencrypt 0
if { [HTTP::header Host] == "host1.domain.com" }{
pool LocalPool
} else {
set reencrypt 1
pool RemotePool
}
}
when SERVER_CONNECTED {
if { $reencrypt == 0 }{
SSL::disable
}
}
01070151:3: Rule [XXX_Passthrough] error: line 1: [invalid keyword { set reencrypt 0 if { [HTTP::header Host] == xxx.xxxxx.com } pool internalweb } must be: priority timing] [when HTTP_REQUEST { set reencrypt 0 if { [HTTP::header Host] == xxx.xxxxx.com } pool internalweb } else { set reencrypt 1 pool xxx-sec.443 }] line 9: [command is not valid in the current scope] [}]
Is reencrypt not valid within the HTTP_REQUEST section?
I seem to bet getting an error in the webserver when a server SSL profile is in place. If I remove the server SSL profile it works properly. Any idea why I might be seeing this error? It looks like it still may be encrypted.
I added some logging into the iRule. According to the logs it looks like it is getting redirected to the proper pool and that the SSL::Disable is triggering:
Jun 13 12:34:16 tmm tmm[1629]: 01220002:6: Rule FOG_Passthrough_443 : local0.“test1”
Jun 13 12:34:16 tmm tmm[1629]: 01220002:6: Rule FOG_Passthrough_443 : local0.“nossl”
Any idea why the web server would be getting 501 errors in the logs? Is this because the browser still has https in the url?
It looks as if I have run into a bug with the 9.4 Hotfix 4 release. I have tried the above code on a 9.2 BigIP and it is working without issue. I am communicating with F5 now to determine what the problem is.
The missing { should be at the end of the line of the first ‘if’:
when HTTP_REQUEST {
set reencrypt 0
if { [HTTP::header Host] == "host1.domain.com" }{
pool LocalPool
} else {
set reencrypt 1
pool RemotePool
}
}
when SERVER_CONNECTED {
if { $reencrypt == 0 }{
SSL::disable
}
}
The rule is accepted, but when it is actioned, I get the following error in the logs:
TCL error: Rule Test-4 HTTP_REQUEST - cant use
non-numeric string as operand of ! while executing if
{ not [HTTP::uri] starts_with /exchange/ ||
[HTTP::uri] starts_with /exchweb/ } { pool content log
local0.test4-1 } else { set disable 0...
The rule i’m trying to use is:
when HTTP_REQUEST {
set disable 1
if { not [HTTP::uri] starts_with "/exchange/" || [HTTP::uri] starts_with "/exchweb/" }
{
pool UAT-content
log local0."test4-1"
} else {
set disable 0
pool OWA-Pool
log local0."test4-2"
}
}
when SERVER_CONNECTED {
if { $disable == 1 }{
SSL::disable
log local0."nossl"
}
}
Reason for this, is that our MS exchange servers have to use SSL, whereas our Apache can’t.. (don’t ask me why..)
I’ve just been shown what is wrong with the TCL.. The problem is having the ‘not’ and the || statemnet.. I’ve swapped things round, and now the “/exchange/” part is working!
Problem now is that the “when SERVER_CONNECTED” part isn’t disabling the SSL like I want it to..
I had a logic error with where I put the parens. This might be a bit more clear:
when HTTP_REQUEST {
if { [HTTP::path] starts_with "/exchange/" ) || [HTTP::path] starts_with "/exchweb/" }{
set disable 0
pool OWA-Pool
log local0. "test4-2"
} else {
set disable 1
pool UAT-content
log local0. "test4-1"
}
}
when SERVER_CONNECTED {
if { $disable == 1 }{
SSL::disable
log local0. "nossl"
}
}
When a request should have SSL disabled, do you see nossl being logged? Are the packets going to the node(s) in the test4-1 pool still encrypted? Also, what version of BIG-IP are you running?
I received confirmation from F5 that this will NOT work in 9.4. For now I think I am going to stick with 9.2/9.3 as it seems we may break iRules by upgrading. F5 has recommended the below:
"In 9.4.x you can redirect from virtual server A to virtual server B, so what you’ll do is evaluate the header, and if you want to send the traffic to the pool that will be ssl encrypted, redirect it to another virtual server, which has that pool assigned.
Check with DevCentral for the fine details, but basically, in 9.4.x you can use “virtual [name of virtual]” the same way you use “pool [name of pool]”"
Can you elaborate on what Support told you? Were you trying something more complicated than selectively disabling server SSL like what you had listed in this thread?
I’ve successfully tested a rule using SSL::disable on 9.4 with a standard virtual server and with ASM. I’m not sure whether it’s true across the board that using SSL::disable in the SERVER_CONNECTED event won’t work.
I’m still looking at solutions to this. F5 did not give any additional information. I think I am going to open a ticket and see how far that gets me. I need to get the below working with 9.4. I’m not thrilled to have to create new virtual servers to handle this as it will add a great deal of clutter and complexity. Have you made any progress with this?
when HTTP_REQUEST {
if { [HTTP::header Host] == "xxx.xxxprd1.xxx.com" or [HTTP::header Host] == "xxx1.xxxprd1.int.xxx.com" }
{
set reencrypt 0
HTTP::header remove "X-Forwarded-For"
HTTP::header insert "ProxyHTTPS" "true"
pool xxx_xxx
} else {
set reencrypt 1
pool xxx1_xxx
}
}
when SERVER_CONNECTED {
if { $reencrypt == 0 }{
SSL::disable
}
}
We do have a very serious push internally to improve iRule documentation, and it’s starting to gain momentum, so we should be doing better as time goes on. That said, this precise issue (CR83395) is documented in the 9.4.2 release notes.