Reputation: 85
I have been trying to figure out whats wrong with my regex
or nginx config
. I have the following location block in my nginx config
location ~ /v1/(tests|my/.*/tests|your/.*/test|our/.*/testers) {
proxy_pass http://127.0.0.1:8000;
}
Nginx is running on port 8080
and i have a simple test web server running on port 8000
. I was testing this with the following paths
http://localhost:8080/v1/tests
(Works)http://localhost:8080/v1/my/a1/tests
(Works)http://localhost:8080/v1/my/%20/tests
(Works)http://localhost:8080/v1/my//tests
(Fails with 404 on nginx server)http://localhost:8080/v1/my/%2F/tests
(Fails with 404 on nginx server)I was wondering why this is, since i was matching with my/.*/tests
, which should have matched empty string too? Am i missing something?
Appreciate the help!
Upvotes: 1
Views: 5074
Reputation: 49702
nginx
normalises the URI before performing tests (such as regex). Part of the normalisation process is to fold consecutive /
s into a single /
.
The result is that my/tests
is not a valid match for your regex.
Upvotes: 1