Traefik is a popular reverse proxy and load balancer that is commonly used in microservices and containerized environments. This application demonstrates how to set up Traefik for load balancing various services and provides example configurations to get you started.
Before you can use this, ensure you have the following prerequisites installed:
- Docker - for containerization.
- Docker Compose - for managing multi-container applications.
- A working knowledge of Traefik's configuration concepts.
Here is a simple diagramatic representation of the system:
Follow these steps to get started:
-
Clone this repository to your local machine:
git clone https://github.com/tanishqmanuja/demo.traefik-load-balancing.git
-
Change into the project directory:
cd demo.traefik-load-balancing
-
Start the application using Docker Compose:
docker compose up -d
-
Access your services through the Traefik reverse proxy, exposed at
http://localhost:8080
.
If you want to rebuild the server, use the Docker Compose command with build flag as follows:
docker compose up --build
The Traefik configuration is defined in the traefik.yaml
& config.yaml
file inside ./config/traefik
directory. You can customize settings such as entry points, middleware, and providers based on your requirements. Refer to the Traefik documentation for detailed configuration options.
Service-specific configurations are defined in the compose.yaml
file. Each service should have its own Docker Compose service definition and can be associated with Traefik labels for routing and load balancing. Refer to the Traefik documentation for details on configuring services with labels.