Traefik V2 and Unifi Controller

I'm trying to use traefik to point to the Unifi Controller in Docker Compose.

The following configuration gives me in the browser:

Bad Request
This combination of host and port requires TLS.

version: '3'
services:
  traefik:
    image: "traefik:v2.0"
    container_name: "traefik"
    command:
      - --log.level=DEBUG
      - --api.insecure=true
      - --providers.docker
      - "--providers.docker.exposedbydefault=false"
      - "--serversTransport.insecureSkipVerify=true"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--certificatesresolvers.myhttpchallenge.acme.httpchallenge=true"
      - "--certificatesresolvers.myhttpchallenge.acme.httpchallenge.entrypoint=web"
      - "--certificatesresolvers.myhttpchallenge.acme.email=something@gmail.com"
      - "--certificatesresolvers.myhttpchallenge.acme.storage=/acme/acme.json"
    ports:
      - "80:80"
      - "443:443"
#      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "/home/ubuntu/acme/:/acme"
    networks:
      - proxy
  unifi:
    image: jacobalberty/unifi
    container_name: unifi
    volumes:
      - ~/unifi:/unifi
    ports:
      - 3478:3478/udp
      - 8080:8080
      - 8443:8443
      - 8843:8843
      - 10001:10001/udp
    restart: unless-stopped
    labels:
      - "traefik.enable=true"

      - "traefik.http.routers.unifi-https.tls=true"

      - "traefik.http.routers.unifi-https.rule=Host(`unifi.lallier.tech`)"
      - "traefik.http.routers.unifi-https.entrypoints=websecure"

      - "traefik.http.routers.unifi-https.tls.certresolver=myhttpchallenge"

      - "traefik.http.middlewares.my-redirect.redirectscheme.scheme=https"
      - "traefik.http.middlewares.my-redirect.redirectscheme.permanent=true"

      - "traefik.http.routers.unifi-https.middlewares=my-redirect"

      - "traefik.http.services.my-service.loadbalancer.server.port=8443"
    networks:
      - proxy
networks:
  proxy:
1 Like

This seems to be a bug. I had to move to the 2.1RC to get my unifi controller running

It's working fine for me on 2.0.5

The solution was the Unifi container needed this label.

- "traefik.http.services.my-service.loadbalancer.server.scheme=https"

Guys, If I got unifi in network host mode and traefik dynamic file config for it, what should it look like?

http:
  routers:
    unifi:
      service: unifi
      rule: "Host(`unifi.host.com`)"
      entryPoints:
        - websecure
      tls:
        certresolver: myresolver

  services:
    unifi:
      loadBalancer:
        servers:
          - url: "https://192.168.0.29:8443"

I was only able to get this to work by specifying in cli of traefik: --serversTransport.insecureSkipVerify=true. But I'm wondering how in this case not globally ignored, but only for this host through the configuration in the file?

Not sure if this is allowed here but once I finished this effort I wrote up a Medium article on it.

Maybe this will help you

I didn't see that u 'are use a network host mode in compose.