I’m new to HAProxy and find the documentation a little confusing for a non-developer. Nonetheless, I’m determined to replace our IIS proxies with HAProxy.
I need to match the pattern “disco” in a query string then redirect to error.html. In IIS, I’d match the entire URL (.*) and then check for “disco” in the query string. If “disco” appeared, I’d redirect to error.html.
With HAProxy, should I be fetching the query-string with “query” and how I would construct the ACL? Any help would be greatly appreciated.
This seems to work (matches string exactly which isn’t ideal):
acl no_discovery query -i disco
http-request redirect location /error.html if no_discovery
This doesn’t seem to work but I’m not sure if I’m organizing my regex correctly:
Thanks for the reply; my apologies for not being more clear. I’m looking to match anything in the query string (after the “?”) that has “disco” in it (case insensitive) and send the traffic to an error page.
Examples that should be matched:
DISCO, disco, Disco, dISCo, Discovery, discovery, DISCOVERY, etc.
I do not recall the precise reason for this requirement but I believe it had something to do with Google Analytics. I could be way off.
I am not concerned about PATH (before the ?) hence the use of “query”. Since I want to do more than match the simply a string, I figured I had to do a regex?
Interesting. I guess I didn’t completely understand what it meant when I first read it in the docs. In your opinion, when is it more appropriate to use a substring vs a regexp? (probably a really amateur question I’m sure)
Regardless, thank you very much for your assistance and insight.