- Linux operating system
- Docker and Docker Compose installed and working
- Base Traefik configuration with Docker Compose.
- Rust application to add hosts to Traefik. (All Rust sources are in
./src)
- Create a Docker network named
web
docker network create web- Replace your email in
docker-compose.yml.
--certificatesresolvers.acmeresolver.acme.email=youremail@email.com
- Run Traefik
docker compose up -d- Download the latest release from GitHub
Go to the Releases page and download the latest version.
Alternatively, you can build from source:
cargo build --release- Run the Rust application
If you built the application from source:
chmod +x ./target/release/add-host
./target/release/add-hostIf you downloaded a release:
chmod +x ./add-host*
./add-host*After following the steps, the application will guide you through the process of adding a new host. The application will add the host to ./config/services/service-name.yml, which is a Docker volume.
- Restart Traefik
chmod +x ./restart
./restart- Configure these labels and networks in your service's Docker Compose file:
services:
your-service:
image: your-image
labels:
- "traefik.enable=true"
# Replace yourhost.com with your host and your-service with your service name
- "traefik.http.routers.your-service.rule=Host(`yourhost.com`)"
- "traefik.http.routers.your-service.tls=true"
- "traefik.http.routers.your-service.tls.certresolver=acmeresolver"
- "traefik.http.routers.your-service.entrypoints=websecure"
# Don't forget to add the service to the web network
networks:
- web
# Don't forget to add the service to the web network
networks:
web:
external: trueTraefik will automatically detect the last exposed port of the service and add it to the router. If you want to use a different port, you can add the following label:
- "traefik.http.services.your-service.loadbalancer.server.port=8080"- Restart Traefik
chmod +x ./restart
./restart
Lucas Ferreira |
Versão em Português