Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
5.0.0
-
None
Description
As described in docs
Once these rules are executed we pick the lowest line number as the match (which replicates first-match-wins).
In fact, we use line number for rank for now. (Github)
However, when we use .include directives to include some other remap config files, there will be overlapping and conflict with the line numbers in each other file.
Examples
remap.config
.include remap1.config .include remap2.config
remap1.config
map /foo/ https://www.yahoo.com
remap2.config
map /foo/bar1 https://www.yahoo.com map /foo/bar2 https://www.yahoo.com
Test Results
$ curl "`hostname`/foo/" -I | grep HTTP HTTP/1.1 200 OK $ curl "`hostname`/foo/bar1" -I | grep HTTP HTTP/1.1 200 OK $ curl "`hostname`/foo/bar2" -I | grep HTTP HTTP/1.1 404 Not Found
When parsing remap1.config, first entry in remap1.config is inserted with rank 0, second with rank 1. Then parsing remap2.config, the single entry is inserted with rank 0 again. So the entry in remap2.config is overlapped with first entry in remap1.config and takes precedence with second entry. This would confuse customers.
I'm considering using a global line number to count each entry, and follow the "first-match-wins" rules. I test with my local environment and it works. However, we are using the line number for debugging output(Github), so the current count variant cln is still needed. This would mess up the code. Appreciate for any suggestions to this issue.