Hi,
Trying to define the forward auth middleware in a resource file. Can I define the routes as such:
routes:
- match: Host('example.com') && Path('/blue')
Thanks for any insight in advance.
Hi,
Trying to define the forward auth middleware in a resource file. Can I define the routes as such:
routes:
- match: Host('example.com') && Path('/blue')
Thanks for any insight in advance.
What's a "resource" file, a Traefik static or dynamic config file?
Matching on routers is usually done with rule, see docs.
# Dynamic Configuration
http:
routers:
dashboard:
rule: Host(`traefik.example.com`) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))
service: api@internal
middlewares:
- auth
middlewares:
auth:
basicAuth:
users:
- "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/"
- "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"
This will be a dynamic config file. Why are there two blocks declared for middlewares in the example given?
dashboard and auth are variable names, that you can define (and rename).
Was that the question?
Essentially, you are defining middlewares in the dashboard block and again in the http block but with more specs. Is that correct?
You assign the middlewares to a router:
which you create in a middlewares section:
I admit, not very logical, should create first, than assign ![]()
Make sure to use PathPrefix, because you service probably has deeper paths than just Path( /blue ) (use backticks!).
This was helpful, thank you!