I'm looking for a way to reroute all requests that have set an account-id in the HTTP header Account-ID
with the last two digits (of a ten digit number) 00
to 05
(to touch only 5% of the total traffic). In addition, if a request has set the HTTP header Server-A
, that request should be forwarded to that server regardless of the set account-id. Otherwise and by default, all traffic should be handled by server-b. My current location-rule looks like this:
location /rest/accounts/ {
if ( $http_account_id ~ '([\d]{8})(0[0-4])') {
proxy_pass http://server-a.company.com;
}
if ( $http_server_a = true) {
proxy_pass http://server-a.company.com;
}
proxy_pass http://server-b.company.com;
}
As I read in the official documents here, if
is considered evil.
Is there a better solution for my approach which isn't considered evil?