DEV Community

Alex Spinov
Alex Spinov

Posted on

Traefik Has a Free API — The Cloud-Native Edge Router

Traefik: Auto-Discovering Reverse Proxy

Traefik automatically discovers services from Docker, Kubernetes, Consul, and other providers. No manual config — add a Docker label, Traefik creates the route. Automatic HTTPS via Lets Encrypt.

Why Traefik

  • Auto-discovery from Docker/K8s/Consul
  • Automatic HTTPS (Lets Encrypt)
  • Dashboard with real-time stats
  • Middleware system (auth, rate limit, compress)
  • Hot reload — no restarts

The Free API

# Get all routers
curl http://localhost:8080/api/http/routers

# Get all services
curl http://localhost:8080/api/http/services

# Get all middleware
curl http://localhost:8080/api/http/middlewares

# Health check
curl http://localhost:8080/api/overview

# Entrypoints
curl http://localhost:8080/api/entrypoints
Enter fullscreen mode Exit fullscreen mode

Docker Auto-Discovery

# docker-compose.yml
services:
  traefik:
    image: traefik:v3.0
    command:
    - --providers.docker=true
    - --entrypoints.web.address=:80
    - --entrypoints.websecure.address=:443
    - --certificatesresolvers.le.acme.email=you@example.com
    - --certificatesresolvers.le.acme.storage=/letsencrypt/acme.json
    - --certificatesresolvers.le.acme.httpchallenge.entrypoint=web
    ports:
    - 80:80
    - 443:443
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - letsencrypt:/letsencrypt

  my-app:
    image: my-app:latest
    labels:
    - traefik.http.routers.myapp.rule=Host(`app.example.com`)
    - traefik.http.routers.myapp.tls.certresolver=le
    - traefik.http.services.myapp.loadbalancer.server.port=8080
Enter fullscreen mode Exit fullscreen mode

Real-World Use Case

A team ran 30 Docker services with nginx. Each new service: edit nginx config, reload, test. Traefik: add Docker label, done. Service auto-discovered in seconds. Cert management: automatic.

Quick Start

docker run -d -p 80:80 -p 8080:8080 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  traefik:v3.0 --api.insecure=true --providers.docker
Enter fullscreen mode Exit fullscreen mode

Resources


Need edge routing automation? Check out my tools on Apify or email spinov001@gmail.com.

Top comments (0)