Setting Up Traefik Proxy with Docker Compose: A Step-by-Step Guide

Learn how to install and configure Traefik Proxy in Docker Compose. Set up entry points, enable service discovery, and use the Whoami container for debugging.

Author

Faiz Ahmed Farooqui
Faiz Ahmed FarooquiPrincipal Technical Consultant.

Date

Mar 17, 2025

Table of Contents

In this post, I'll show you how to install Traefik Proxy — the cloud native application proxy in our Docker Compose file and utilize it in our architecture with a sample service container. Traefik Proxy was discussed in my previous post — How much do you know "Traefik" proxy?

As a baseline, I'm assuming you're familiar with Docker and Docker Compose files.

Let's get started —

Docker Compose

  • Add the following content to your docker-compose.yml file

Details (of the content mentioned in Docker Compose file)

  • Replace localhost with your own domain or sub-domain in service container whoami
  • Run docker-compose.yml file by using the command docker-compose up -d
  • Your server should be up and running. Visiting http://localhost:1337/whoami, will show you all request headers
  • I'm using Traefik's whoami service as an example, it is a tiny Go server that prints os information and HTTP request to output

  • The above mini snapshot shows how we define entry point in Traefik
  • This allows us to "open and accept" HTTP traffic

  • The above mini snapshot shows how we configure & expose Traefik's API and Dashboard.
  • By default, Traefik will listen on port 8080 for API requests
  • This is a fully optional step; we may disable the Dashboard and secure APIs if you do not want to.

  • To enable and customise the log and it's level, we can use the command as mentioned above
  • Accepted values, in order of severity - DEBUGINFOWARNERRORFATAL & PANIC

  • To enable docker as a providers for Traefik configuration, we set the value as true against providers.docker
  • If we want to enable all the service containers within the docker-compose file, we can set the value as true against providers.docker.exposedbydefault
  • But, I'd recommend to not expose all service containers unless really needed
  • If choose to not explicitly expose all your service containers, then you'd need to enable each container service by setting traefik.enable as true
  • To allow request only from your predefined entry point, we set traefik.http.routes.whoami.entrypoint with the name value we defined in our traefik service - in our case, it is web

Screenshots

traefik dashboard

Traefik Dashboard's Routers List

traefik dashboard routers list

Whoami Service Container

whoami service container

Summary

After reading this article, you will have a fundamental grasp on how to setup Traefik Proxy in your Docker Compose with a service.

And I strongly advise everyone to have the "traefik/whoami" service container ready for debugging request headers if something goes wrong.

Source: This blog is authored by Faiz Ahmed, Principal Technical Consultant at GeekyAnts. Originally published on Hashnode: Read here.

SHARE ON

Related Articles.

More from the engineering frontline.

Dive deep into our research and insights on design, development, and the impact of various trends to businesses.

From RFPs to Revenue: How We Built an AI Agent Team That Writes Technical Proposals in 60 Seconds
Article

Apr 9, 2026

From RFPs to Revenue: How We Built an AI Agent Team That Writes Technical Proposals in 60 Seconds

GeekyAnts built DealRoom.ai — four AI agents that turn RFPs into accurate technical proposals in 60 seconds, with real-time cost breakdowns and scope maps.

How We Built an AI System That Automates Senior Solution Architect Workflows
Article

Apr 6, 2026

How We Built an AI System That Automates Senior Solution Architect Workflows

Discover how we built a 4-agent AI co-pilot that converts complex RFPs into draft technical proposals in 15 minutes — with built-in conflict detection, assumption surfacing, and confidence scoring.

AI Code Healer for Fixing Broken CI/CD Builds Fast
Article

Apr 6, 2026

AI Code Healer for Fixing Broken CI/CD Builds Fast

A deep dive into how GeekyAnts built an AI-powered Code Healer that analyzes CI/CD failures, summarizes logs, and generates code-level fixes to keep development moving.

A Real-Time AI Fraud Decision Engine Under 50ms
Article

Apr 2, 2026

A Real-Time AI Fraud Decision Engine Under 50ms

A deep dive into how GeekyAnts built a real-time AI fraud detection system that evaluates transactions in milliseconds using a hybrid multi-agent approach.

Building an Autonomous Multi-Agent Fraud Detection System in Under 200ms
Article

Apr 1, 2026

Building an Autonomous Multi-Agent Fraud Detection System in Under 200ms

GeekyAnts built a 5-agent fraud detection pipeline that makes decisions in under 200ms — 15x cheaper than single-model systems, with full explainability built in.

Building a Self-Healing CI/CD System with an AI Agent
Article

Mar 31, 2026

Building a Self-Healing CI/CD System with an AI Agent

When code breaks a pipeline, developers have to stop working and figure out why. This blog shows how an AI agent reads the error, finds the fix, and submits it for review all on its own.

Scroll for more
View all articles