I’m new at using a LTM. I’m using ProxyPass V10 - http://devcentral.f5.com/wiki/default.aspx/iRules/ProxyPassV10.html - I wrote a script to convert the almost 1,000 rules from our Reverse Proxy to this format (with some cleanup too) and it’s working fine. The issue I’m having is with the handling of mistakes (mistyped URLs or similar) for which I don’t have a solution.
I tried to add a 2nd iRule where I do some redirections but the 404 isn’t always a good test as the error the user gets is a connection reset (as no data is sent by the web servers if the URL is invalid).
- be redirected to an error.html page when no pool is dynamically selected (I don’t have a default pool) regardless of the URL typed
If you set even a dummy default pool, ProxyPass will select it if there isn’t a match in the HTTP_REQUEST event for the requested host and/or URI against the ProxyPass datagroup. So you could put your second iRule at a later priority (when HTTP_REQUEST priority 501) and then check if ‘[LB::server pool] eq $default_pool’. If so, then no match was found in the ProxyPass iRule and you could then send a redirect to an error URL.
- be redirected to an error.html page when the user types a wrong URL and the web server doesn’t return any response
I can’t think of a way to handle this if the server sends no HTTP response for an invalid request. Conceptually, you could try to increment a counter on each HTTP request, decrement the counter on each response and then look for an incremented count when the server closes the connection. However, you cannot send an HTTP response from the SERVER_CLOSED event. So I’m not sure this is possible.
Can you change the server behavior to send a 404 or any other specific status?
If you’re rewriting the request using HTTP::uri, the URI would be updated and then sent to the default pool. If the default pool doesn’t include valid IP:ports, then the request would fail. I thought you wanted to send an HTTP redirect. In that case, the client should get the redirect.
Ah, I forgot that the ProxyPass iRule would be redirecting some requests. You could set a variable at the beginning of HTTP_REQUEST (set redirected 0) and then set it to 1 for the two HTTP::redirects. You could then check if $redirect==0 before trying to redirect in the second iRule.
I don’t think I was very clear in the last post… I was trying to suggest that you modify the ProxyPass iRule to add a “redirected” variable to track whether the ProxyPass iRule had attempted a redirect. So you could add ‘set redirected 0’ at the beginning of the ProxyPass HTTP_REQUEST event, add ‘set redirected 1’ before each HTTP::redirect command in the ProxyPass iRule and then only use HTTP::redirect in the second iRule if ‘$redirected==0’.
Your posting was very clear but it introduced the issue I showed. I’ve rewritten my rules since and I’ll try a different approach, I’m sure you’ll see a post soon