I'm trying to run Traefik as a reverse proxy for some apps in localhost.
In the configuration file, I configured 3 routers and 2 services. The goal is to proxify two applications I have on localhost 8080 and localhost 3000 (dev.test.fr is equivalent to localhost)
The configuration :
api:
dashboard: true
insecure: true
entryPoints:
http:
address: ':80'
traefik:
address: ':8081'
http:
routers:
myapi:
rule: Host(`dev.test.fr`) && PathPrefix(`/api`)
service: service-api
traefik:
rule: Host(`dev.test.com`)
service: api@internal
myfront:
rule: Host(`dev.test.fr`)
service: service-front
services:
service-api:
loadBalancer:
servers:
- url: 'http://localhost:8080/'
service-front:
loadBalancer:
servers:
- url: 'http://localhost:3000/'
log:
level: DEBUG
accessLog: {}
However if I go on the traefik dashboard, I don't see any of my router or service (except the internal api of traefik)
I'm not an expert on traefik so I probably miss something obvious in this configuration file.
I answer to my own question. Indeed, my config file was incorrect. It is important to have two files (and not one)
The first one is the configuration of Traefik itself
api:
dashboard: true
insecure: true
entryPoints:
http:
address: ':80'
traefik:
address: ':8081'
providers:
file:
directory: "traefik"
log:
level: DEBUG
accessLog: {}
In this file, it's possible to configure the provider, even if it's a plain text file. It's not possible to have the configuration of the router in the same file. The provider here is :
providers:
file:
directory: "traefik"
And in this directory, I have another configuration file with the definition of routers and services :
http:
routers:
myapi:
rule: Host(`dev.malt.fr`) && PathPrefix(`/api`)
service: service-api
entryPoints:
- http
myfront:
rule: Host(`dev.malt.fr`)
service: service-front
entryPoints:
- http
services:
service-api:
loadBalancer:
servers:
- url: 'http://localhost:8080/'
service-front:
loadBalancer:
servers:
- url: 'http://localhost:3000/'