A Squid server at work is being used to route requests through multiple external IP addresses. I'm doing the named-IP routing with the solution at my own question on Unix.SE. Another piece of the puzzle I need to add now is random selection if the custom header isn't set.
I know there's a 'random' directive that will set an ACL based on a probability, but the examples online are sketchy at best.
I need a way to split all of my traffic randomly across 20 IP addresses, UNLESS a specific header is set, at which point the header (aka ACL) should take priority and force an outbound IP address. How can I do this with ACL in squid?
Best Answer
I'm not a squid expert but i've used it a fair bit and think this might work.
Change 10.0.0.X to your ip addresses for your outgoing connections, obviously those addresses need to be available on the system, so they will need to be static ips.
Change 10.0.0.1 at the end to whatever connection you want the traffic w/header set to use.
The header from the browser needs to have the specified name and have content that matches the regex.
Again Im not an expert but its worth a go.
Also this is 20, 1 in 20 chances to match the random probabilities, it theoretically must match one, but its not guaranteed, so the first line should set the default connection.
Edit:
Updated to allow connection selection, it needs testing, because i can't be 100% sure it will work as required.