traefik
traefik copied to clipboard
PathPrefix Matcher is case sensitive - need doc update?
Do you want to request a feature or report a bug?
Feature
What did you do?
- Create a front end
PathPrefix
matcher rule - Tested route with various cases ... only the exact match, works. The rest 404.
What did you expect to see?
- Matches the route, regardless of case
What did you see instead?
- 404's for all various casings except the exact match
Output of traefik version
: (What version of Traefik are you using?)
Version: v1.7.2
Codename: maroilles
Go version: go1.11.1
Built: 2018-10-04_01:44:36PM
OS/Arch: linux/amd64
What is your environment & configuration (arguments, toml, provider, platform, ...)?
Labels via docker-compose.yml
accounts.api:
image: hornet/accounts.api
build:
context: ./
dockerfile: src/Services/Accounts/Accounts.Api/Dockerfile
networks:
- backend
depends_on:
- ravendb.data
container_name: accounts.api
labels:
- "traefik.frontend.rule=PathPrefix:/accounts,/account,/authenticate"
- "traefik.backend=accounts.api"
So when I was testing the following routes to that sample service, I noticed some didn't work and it was when i had some mismatched casing.
eg.
- HTTP GET /accounts - 200 (with payload)
- HTTP GET /Accounts - 404
- HTTP GET /accOuNtS - 404
sure, the last one is pretty obvious that it could be a casing issue, but the second one looked ok .. and didn't spark any thoughts that the 404 was due to case-sensitivity of Traefik.
So at first I thought it might be a bug. I checked the official docs for Matchers and they do say:
- PathPrefix: /products/, /articles/{category}/{id:[0-9]+}
- Match request prefix path. It accepts a sequence of literal and regular expression prefix paths.
So I just thought (being a newbie here) that
- the example routes above are case insensitive
- the regex stuff in the expression (if you choose to do that) would be mainly for some custom numbers/names/etc ... but again still case insensitive.
So TIL that regex are case sensitive. GG me.
So .. even though the error lies with me / my lack of knowledge / oversight ... it might be nice to add some warning or notice, etc. .. that the routes are case sensitive unless you specify case insensitivity as part of your regex expression.
The other part of me was this quote:
It accepts a sequence of literal
Literal? so again, does literal mean "case sensitive, literally how it's defined in the .yml
file" .. It seems so, but again, easy for newbies like me to miss/oversight/etc.
Maybe include an example(s) for case insensitive routes/endpoints, also. Google came up with #1202 which helped me add this into my .yml
file.
Also, possible link/ref to #1411
Relates to #4100
Hello, any updates on this?
quoting https://github.com/traefik/traefik/issues/4100#issuecomment-663287121
Just to get an answer in the books... Standard inline flags seems to be supported by the regex engine, so (?i:) works for case-insensitive matching:
rule: "PathPrefix(/{path:(?i:customerconfig)}
)"