Port is missing even though traefik.http.services.<name-of-your-choice>.loadbalancer.server.port is used

I'm using the following files

docker-compose.yml

version: '3'

services:
  frontproxy:
    image: traefik:2.2.6
    command: --api --docker --docker.swarmmode # Enables the web UI and tells Træfik to listen to docker
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - /path/to/logs:/logs
      - /path/to/certs:/etc/ssl:ro
      - /path/to/traefik.toml:/etc/traefik/traefik.toml:ro
      - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
    networks:
      - traefik-net
    deploy:
      placement:
        constraints:
          - 'node.role == manager'
          - 'node.platform.os == linux'
      labels:
        traefik.enable: 'true'
        traefik.http.services.frontproxy.loadbalancer.server.port: 8080 # API (web UI)
        traefik.http.routers.router0.rule: Host(`traefik.my-domain.com`)
        traefik.docker.network: traefik-net

networks:
  traefik-net:
    external: true

traefik.toml

[entryPoints]
  [entryPoints.http]
    address = ":80"
  [entryPoints.https]
    address = ":443"

# Redirect to https
[http.middlewares]
  [http.middlewares.test-redirectscheme.redirectScheme]
    scheme = "https"
    permanent = true

[[tls.certificates]]
  # wildcard certificate *.my-domain.com
  certFile = "/etc/ssl/my-domain.com.crt"
  keyFile = "/etc/ssl/my-domain.com.key"

[providers]
  providersThrottleDuration = "2s"
  [providers.docker]
    watch = true
    swarmMode = true
    swarmModeRefreshSeconds = "15s"
    exposedByDefault = false

[api]
  insecure = true

[log]
  filePath = "/logs/error.log"

[accessLog]
  bufferingSize = 0
  filePath = "/dev/stdout"

I create the network (used by other stacks)

docker network create --driver=overlay traefik-net

and run

docker stack deploy frontproxy -c docker-compose.yml

I expect to be able to access Traefiks web UI at https://traefik.my-domain.com, but I get

\"frontproxy-frontproxy\" error: port is missing" providerName=docker container=frontproxy-frontproxy-le6qibl1w2vi9a5cvp7vcx6o0

in /path/to/logs/error.log

What am I missing?

The correct cli parameter for swarm mode is --providers.docker.swarmmode.

You are also missing the label for the api service traefik.http.routers.router0.service: api@internal

1 Like

Thanks for your answer and sorry for the late response.

Are CLI parameters even required or can I define all values in the traefik.toml file?

Probably a stupid question, but does it have to be api@internal or can it be foo@internal? Where is api@internal declared? Do I only refer to it or do I declare it by using it?

Yes you can do them in a toml file if you wish.

api@internal is the service for the traefik api and dashboard. It is declared when you setup a router for traefik.

See: Traefik Dashboard Documentation - Traefik in the "Dashboard Dynamic Configuration Examples"

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.