Before starting, you need to update your /etc/hosts
file:
$ sudo vim /etc/hosts
And past this line at the end of the file:
127.0.0.1 backend.localhost frontend.localhost
Install the project on your local machine:
$ git clone https://github.com/guillaumebriday/traefik-file-config-example.git
$ cd traefik-file-config-example/example
$ yarn install
$ yarn run nodemon index.js
Open a new terminal and setup Traefik:
$ brew install traefik
$ cd traefik-file-config-example
$ traefik -c traefik.toml
Open http://localhost:8080 to see the Traefik Web UI.
Open http://backend.localhost to see your app on port 3000.
Open http://frontend.localhost to see your app on port 3001.
Open http://backend.localhost/github to be redirected to https://github.com/guillaumebriday/traefik-file-config-example.
Run curl to see the custom headers:
$ curl -I http://backend.localhost
...
X-Custom-Header: Leave a star
X-Frame-Options:
Uncomment the basicAuth
related line in the rules.toml
file to try basic auth on http://backend.localhost.
You can tail the log:
$ tail -f tmp/traefik.log
$ tail -f tmp/access.log
Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.
This project is released under the MIT license.