Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix prefix path type if the path matches a domain
Map keys are built using sysadmin/user defined hostnames and paths. We concatenate both when building the map file, and also concatenate hdr(host) and path from the incoming request. This works pretty well on beg and reg match types. Since v0.11 we have also dir (Prefix from ingress pathType) and str (Exact). The later also work well with this construction, but str (Prefix) does not behave as expected from the end user perspective. Take this map example: domain.local/ backend1 sub.domain.local/ backend2 and this request: sub.domain.local/domain.local A begin or regex match type would choose backend2, and this is the expected behavior for prefix as well, but due to how haproxy implements -m dir, backend1 would be chosen. When using dir match type, haproxy slices the request using the slash as separator. These slices tries to match a whole map entry, but without starting from the beginning. A hash # is added after the hostname and before the first slash, leaving the first item of the slice as unique. This is only needed for dir / Prefix, but will not hurt other match types and does not have any performance degradation. Now the map looks like this: domain.local#/ backend1 sub.domain.local#/ backend2 and the request is internally converted to this: sub.domain.local#/domain.local Should be merged as far as v0.11.
- Loading branch information