Nodevisor Docs
Services

Traefik

Reverse proxy with automatic SSL, dashboard, and Docker provider integration.

Overview

The Traefik service provides a production-ready reverse proxy with automatic SSL certificate management via Let's Encrypt, an optional dashboard, and automatic Docker service discovery. It extends WebProxy and runs in global mode on manager nodes.

Traefik automatically routes traffic to your web services (NodeWeb, Nextjs, Whoami) based on domain labels — no manual nginx or HAProxy configuration needed.

Quick Start

import { DockerCluster, Traefik } from '@nodevisor/docker';

const cluster = new DockerCluster({ name: 'production', ... });

cluster.addDependency(new Traefik({
  ssl: {
    email: 'ops@example.com',
    redirect: true,
  },
}));

Configuration

TraefikConfig

OptionTypeDefaultDescription
namestring'traefik'Service name
versionstring | number'3.1.7'Traefik version
imagestring'traefik:{version}'Docker image
sslSSLConfigundefinedSSL/TLS configuration (see below)
dashboardDashboardConfigundefinedDashboard configuration (see below)
dockerUnixSocketstring'/var/run/docker.sock'Path to Docker socket
healthcheckDockerHealthcheckConfigBuilt-in (see below)Custom health check config

SSLConfig

OptionTypeDefaultDescription
emailstringrequiredEmail for Let's Encrypt registration
portnumber443HTTPS port
storagestring'/letsencrypt/acme.json'Path to store certificates inside the container
redirectbooleanundefinedRedirect all HTTP traffic to HTTPS

DashboardConfig

OptionTypeDefaultDescription
hoststringundefinedDomain for the dashboard (e.g., 'traefik.example.com')
usernamestring'admin'Basic auth username
passwordstring | falserequiredhtpasswd hash for basic auth, or false to disable auth
port80808080Dashboard port (fixed)

The dashboard password must be an htpasswd-hashed string. Generate one with: htpasswd -nb admin yourpassword

Health Check

Traefik includes a built-in health check using the ping endpoint:

PropertyValue
Commandtraefik healthcheck --ping
Interval10s
Timeout2s
Retries3
Start period10s

The health check enables Traefik's --ping entrypoint on port 8080 internally.

Volumes

VolumeTargetTypeDescription
docker-socket/var/run/docker.sockbind (read-only)Docker socket for service discovery
letsencrypt/letsencryptvolumeSSL certificate storage (only when ssl is configured)

Ports

PortProtocolModeDescription
80TCPhostHTTP traffic
443TCPhostHTTPS traffic (only when ssl is configured)

Ports use host mode instead of ingress to preserve real client IPs and ensure proper ACME challenge handling.

Docker Provider

Traefik automatically configures the following Docker provider settings:

  • --providers.docker — Enable Docker provider
  • --providers.swarm — Enable Swarm provider (when using Docker Swarm)
  • --providers.docker.exposedbydefault=false — Containers are not exposed without explicit labels
  • --providers.docker.network — Uses the cluster's network for communication

Usage with DockerCluster

import {
  DockerCluster, DockerNode, ClusterUser,
  Traefik, Postgres, NodeWeb, DockerRegistry,
} from '@nodevisor/docker';

const cluster = new DockerCluster({
  name: 'production',
  nodes: [new DockerNode({ host: '10.0.0.1' })],
  users: [new ClusterUser({ username: 'root', privateKeyPath: '~/.ssh/id_ed25519' })],
  registry: new DockerRegistry({
    server: 'ghcr.io',
    username: 'myorg',
    password: process.env.REGISTRY_TOKEN!,
  }),
});

// Reverse proxy with SSL and dashboard
cluster.addDependency(new Traefik({
  ssl: {
    email: 'ops@example.com',
    redirect: true,
  },
  dashboard: {
    host: 'traefik.example.com',
    username: 'admin',
    password: process.env.TRAEFIK_PASSWORD_HASH!,
  },
}));

// Database
cluster.addDependency(new Postgres({
  database: 'myapp',
  password: process.env.DB_PASSWORD!,
}));

// Application — automatically uses Traefik for routing
cluster.addDependency(new NodeWeb({
  name: 'api',
  appDir: './apps/api',
  domains: ['api.example.com'],
  port: 3000,
}));

await cluster.deploy();

On this page