Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paths matching order #1011

Closed
Vad1mo opened this issue Jan 2, 2017 · 4 comments
Closed

Paths matching order #1011

Vad1mo opened this issue Jan 2, 2017 · 4 comments

Comments

@Vad1mo
Copy link

Vad1mo commented Jan 2, 2017

What version of Traefik are you using (traefik version)?

1.1.2

What did you do?

I have two services "Website" and "API"

The API Service should receiver traffic for

  • app.company.com/v2/*

The Website should receive traffic for

  • app.company.com/*
  • app.company.com/v2/token
  • app.company.com/v2/webhook

I crate following rules for website

  • traefik.frontend.rule=Host:app.company.com;Path:/,/{p:.+},/v2/token,/v2/webhook

I crate following rules for API

  • traefik.frontend.rule=Host:app.company.com;Path:/v2/,/v2/{p:.+}

What did you expect to see?

I expected that for /v2/token the website rule would wind and for anything else with /v2/*the API Rule. I also expected that the /{p:.+} rule in website would not apply because /v2/* on the API matches better.

Web

When the longest rule is applied then it should work as expected.

What did you see instead?

All traffic goes to web even /v2/info although API Rule has a longer matcher then Web.

@Vad1mo Vad1mo changed the title Paths matching Paths matching order Jan 2, 2017
@dtomcej
Copy link
Contributor

dtomcej commented Jan 5, 2017

If you are not using toml to define your frontends, your issue may not be matching order, your issue could be the fact that you have overlapping rules.

Can you provide a sanitized toml or debug log?

@Vad1mo
Copy link
Author

Vad1mo commented Jan 5, 2017

here is sanitized docker compose file.

the hello-world-service will printout its hostname/ip and the request path. When I run this example the API service is never triggered.

  version: '2'
  services:
#---#
    proxy:
      image: traefik:v1.1.2-alpine
      command: --web --docker --docker.domain=docker.localhost --logLevel=DEBUG --docker.endpoint=unix:///var/run/docker.sock
      ports:
        - 80:80
        - 443:443
      labels:
        - traefik.enable=false
      volumes:
        - /var/run/docker.sock:/var/run/docker.sock
        - /dev/null:/traefik.toml
#---#
    service_web:
      image: vad1mo/hello-world-service
      hostname: web
      labels:
        - traefik.backend=web
        - traefik.port=5050
        - traefik.frontend.rule=Host:sample.127.0.0.1.xip.io;Path:/,/{a:.+},/v2/token,/v2/webhook
        - traefik.frontend.entryPoints=http
#---#
    service_api:
      image: vad1mo/hello-world-service
      hostname: api
      labels:
        - traefik.backend=api
        - traefik.port=5050
        - traefik.frontend.rule=Host:sample.127.0.0.1.xip.io;Path:/v2/,/v2/{b:.+}
        - traefik.frontend.entryPoints=http

@pascalandy
Copy link
Contributor

@Vad1mo

I'm really curious about Path:/,/{p:.+},/v2/token.

What means {p:.+} ?

I use --label traefik.frontend.rule="Host:example.com;PathPrefixStrip:/nginxtest", but run into another issue

@Vad1mo
Copy link
Author

Vad1mo commented Feb 9, 2017

Routes can be named and p is a name. I tried without as plain /.+ and it wasn't working at all so I used this schema event if I didn't care about the name.
traefik is using https://github.com/gorilla/mux so you can find some more reference there.

The problem is that the routes are not flexible enough as you wuld expect it.
At the end of the day I gave up using traefik and switched to openresty as its more understandable and programmable at least for someone who knows nginx.

@traefik traefik locked and limited conversation to collaborators Sep 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants