we are using F5 load balancers for our Internet environment. There is now a requirement during customer login to download a trojan detection script at an external company. But for the client point of view this script should be hosted from our own domain otherwise personal firewalls will block this script.
The plan is to create a pool an add this external website as a poolmember and have the F5 based on a specific URI to rewrite the URL to the external website and using SNAT to get the external script.
The problem is we are now doing a POC in our DTA environment but here the F5 does not have a direct Internet connection. The only option is to go via our browser proxies.
So I have created a pool wiht the proxy as a member and are using TCP 8080, redirecting normal HTTP traffic via the proxy is working, but the website hosting the external script is running on HTTPS.
The problem is that the proxy for HTTPS traffic is expecting a HTTP CONNECT request instead of a GET which is standard used for HTTP.
Is there anyway to change the HTTP method on the F5 from GET to CONNECT?
I know you can read the method via HTTP::method but I have not found an option to actually change the method to CONNECT.
Hmm… You’re wanting the LTM to be an HTTP client to a proxy…
OOTB this isn’t going to happen. Hwoever you should be able to get something up & running with an iRule. But at first glance, it’s not going to be terribly simple one as the iRule is going to have to negotiate a TLS/SSL connection on the fly after the CONNECT (The SMTPTLS iRule shows how this can be done on the client side, it should be possible to manipulate the iRule to doit on the server side instead).
I think setting up the F5 to be a SSL client shouldn’t be a problem, this should be accomplished by using a standard serverssl profile without any key or certificate specified. The F5 should than act as an client in the SSL handshake.
Since we already use an iRule to select the pool based on the URI, I can disable ssl for all other URI’s in the irule.
The proxies have been setup in transparent mode for SSL traffic, so they should not be involved in the SSL process. I think my biggest problem is getting the F5 to use a HTTP CONNECT method instead of the standard GET.
The proxies have been setup in transparent mode for SSL traffic, so they should not be involved in the SSL process. I think my biggest problem is getting the F5 to use a HTTP CONNECT method instead of the standard GET.
If the proxies really do work in transparent mode for SSL you won’t need the CONNECT method. CONNECT is only used by HTTP clients when they know about the proxy. In transparent mode the clients don’t know there is a proxy and they will just try to connect directly to the target, by issuing a tcp connection to server:443.
So, your ssl server profile should work out of the box.
Let’s assume the SSL connection works, then you still need to do this:
1.) Rewrite the URI to the location of the script “[HTTP::uri]”
2.) Rewrite the HOST header “[HTTP::header Host] replace”, otherwise the target server might not accept the request.
“TCP::respond” to send the CONNECT command. Very nice. Thanks for that one!!
Now, to enable SSL using a server ssl profile, just use ssl:disable and ssl:enable at the right moment (samples are available on devcentral) and it would be possible to create what Remco was asking for, at least as I understood it:
However that’s not even necessary if the clients are using SSL themselves. The SSL handshake would then take place between the clients and the HTTPS servers directly (as shown with your curl example).
I have managed to indeed get the CONNECT message towards the proxy and getting the 200 OK reply indicating the proxy is in SSL transparent mode.
My next challenge is getting the F5 to start the ssl handsake with the target web-server.
Our challenge is exaclty a little bit more complicated than described in the last post. I will try to explain what we are trying to do.
For our main domain the F5 is setup to do SSL offloading, so the client SSL connection is termintated on the F5. A iRule is than used to load balance to different application pools based on the URI requested. For all normal pools no SSL is used.
One URI is used to download a java script for trojan detection on the client PC, so the F5 should do the following task when the URI is matching in the HTTP_REQUEST event:
1. change the host to the URL of the external company providing the script (rewrite HTTP host header)
2. remove specific application session cookie (cookie remove)
3. send CONNECT message to proxy pool to tell proxy SSL session is coming up
4. start SSL handsake with external website.
5. reply of external website should be directed back to the orginal client requesting the uri.
I have been trying to use the suggested iRule in combination with the already configured HTTP_REQUEST event but no success yet.
In the SERVER_CONNECTED event I have disabled SSL SSL::disable to have the CONNECT message send as normal TCP traffic. But the problem is once the 200 OK has been received from the proxy SSL should be enabled again and the HTTP request with the change host should be send to the proxy.
I am struggling in finding the correct spot to enable SSL again.
In a tcpdump I did, it looks like the F5 is sending the rewritten HTTP request immediatly after the CONNECT message before the SSL handsake is started. Causing the proxy to reply with a 400 bad request message.
thanks for your suggestions. I just made the changes and it all looks like to be working as we planned.
The extra VIP for setting up the connection via the proxy does the trick in seperating the required CONNECT message and the HTTP modification needed on the client request.
Remco we’re seeing more and more requests from customers for this type of web proxy functionality. If you’d like to see F5 add this functionality to the product, you could get in touch with F5 Support or your F5 SE/partner to request it.
i’m currently trying to use this brilliant solution to send http to froward proxy server, but i’m encountering an issue :
I have configured the same setup (with 2 VS)
But when the second VS sends the “HTTP CONNECT” to the proxy, it doesn’t wait for the reply “200 OK” and just sends the “CLIENT HELLO” received from the first VS.
Result => when receiving the 200 OK from the proxy, the SSL session doesn’t get established as the client waits for the “SERVER HELLO” which never arrives.
Here is the diagram observed between F5 and proxy :
(F5 → Proxy) CONNECT toto.com:443 HTTP/1.1
(F5 → Proxy) CLIENT HELLO
(Proxy → F5) HTTP/1.1 200 Connection established …
Here is the expected diagram :
(F5 → Proxy) CONNECT toto.com:443 HTTP/1.1
(Proxy → F5) HTTP/1.1 200 Connection established
(F5 → Proxy) CLIENT HELLO
(Proxy → F5) SERVER HELLO, CERTIFICATE, SERVER HELLO DONE, …
Hi We are trying something similar. We want to publish a web page with a blog on that page pulled from a third party. I can capture the content by looking for a uri starting with /news-and-blog/ I send this to a proxy and rewrite the host header. This sends the blog content to a virtual server (with the proxy server as a pool member). This works OK for HTTP traffic but if we try to use HTTPS it fails. The proxy always sees HTTP for some reason. I have also tried substituting the pool for the VIP in this iRule without success.
when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/news-and-blog/" } {
HTTP::header replace Host "myblog-uat.third_party.com"
virtual /S1SIL/VS_S2S_PROXYHTTP_INTERNAL_LIVE
log local0. "Sending Blog content slblog-uat.third_party.com[HTTP::uri]to 3rd pary"
} else {
pool pool_iab3
}
}
The site at the Third party can only listen on HTTP or HTTPS, not both so we have to get them to switch when we are testing.
@Drew: are you saying that you’re creating a composite site by using content from multiple origins?
If so, you could also accomplish that by creating pools for each of the environments. You can then select a pool based on the URI. The VIP for port 443 can be configured to pull that information from pools for any port (using port translation).
The iRule would look like this:
when HTTP_REQUEST {
if { [string tolower [HTTP::path]] starts_with "/news-and-blog/" } {
pool cloud_news-and-blog_80_pool
persist none
} else {
pool pool_iab3
persist none
}
}