Streamline microservices deployment with Traefik and Docker Compose. And secure your website with security headers.
-
Score on : securityheaders.com
-
Score on : observatory.mozilla.org
Traefik is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy. Traefik integrates with your existing infrastructure components and configures itself automatically and dynamically.
Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application's services.
Make sure you have the following installed:
- Clone the repository and navigate to it:
git clone https://github.com/Lindwen/traefik-docker-compose.git
cd traefik-docker-compose
- Create
acme.json
file for traefik:
touch acme.json
chmod 600 acme.json
- Configure the
traefik.toml
file by changing the email address:
# Change the email address
[certificatesResolvers.letsencrypt.acme]
email = "YOUR_EMAIL_ADDRESS"
- Configure labels:
Edit docker-compose.yml
and example/docker-compose.yml
:
vi docker-compose.yml
# [required] Change the domain name
- "traefik.http.routers.<service>.rule=Host(`YOUR_DOMAIN_NAME`)"
# example:
- "traefik.http.routers.dashboard.rule=Host(`traefik.example.com`)"
# [required] Add auth
- "traefik.http.routers.<service>.middlewares=auth"
- "traefik.http.middlewares.auth.basicauth.users=<username>:<password>" # password generated with htpasswd (Bcrypt) and double $
# example:
- "traefik.http.routers.dashboard.middlewares=auth"
- "traefik.http.middlewares.auth.basicauth.users=Example:$$2a$$10$$Bls.hNkCW3m4lBz9a592IOfom6U0dmFvIP9UUz.4VWbWF0x8Kn3WG"
To start traefik:
docker compose up -d
To stop the container:
docker compose down
To view live logs:
docker compose logs -f
You can go to check your website to:
https://traefik.example.com
And register with your user / password
- Go to example dir:
traefik-docker-compose/example
- Edit
.env
(remove .dist)
# The service name (for example "website")
service=
# The domain name (for example "website.domain.tld")
domain=
- Launch :
docker compose up -d
If you encounter any issues, need help, or have questions, please don't hesitate to reach out. You can create an issue here on GitHub. We're here to assist you and improve this project based on your feedback.
- Click on the "Issues" tab at the top of this repository.
- Click the green "New Issue" button.
- Provide a descriptive title and detailed description of the problem you're facing or the help you need.
- Submit the issue, and we'll get back to you as soon as possible.
Your feedback is valuable, and we appreciate your contributions to making this project better.
- PaulsBlog - for the security headers
- Solution-Libre - for the TLS file