# Traefik V2 and Unifi Controller

**URL:** <https://community.traefik.io/t/traefik-v2-and-unifi-controller/3231>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [November 30, 2019, 3:08am UTC](https://community.traefik.io/t/traefik-v2-and-unifi-controller/3231 "2019-11-30T03:08:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![alallier](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/alallier/32/1206_2.png) [@alallier](https://community.traefik.io/u/alallier)\
**Post date:** [November 30, 2019, 3:08am UTC](https://community.traefik.io/t/traefik-v2-and-unifi-controller/3231/1 "2019-11-30T03:08:07Z")

</div>

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.

```auto
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:

```

---

<div class="post-metadata">

**Author:** ![ToeiRei](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/toeirei/32/1208_2.png) [@ToeiRei](https://community.traefik.io/u/ToeiRei)\
**Post date:** [November 30, 2019, 8:41pm UTC](https://community.traefik.io/t/traefik-v2-and-unifi-controller/3231/2 "2019-11-30T20:41:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cwhits](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/cwhits/32/8745_2.png) [@cwhits](https://community.traefik.io/u/cwhits)\
**Post date:** [December 2, 2019, 9:12pm UTC](https://community.traefik.io/t/traefik-v2-and-unifi-controller/3231/3 "2019-12-02T21:12:46Z")

</div>

It's working fine for me on 2.0.5

---

<div class="post-metadata">

**Author:** ![alallier](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/alallier/32/1206_2.png) [@alallier](https://community.traefik.io/u/alallier)\
**Post date:** [December 3, 2019, 12:41pm UTC](https://community.traefik.io/t/traefik-v2-and-unifi-controller/3231/4 "2019-12-03T12:41:04Z")

</div>

The solution was the Unifi container needed this label.

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

```

---

<div class="post-metadata">

**Author:** ![SoulAssassin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/soulassassin/32/4409_2.png) [@SoulAssassin](https://community.traefik.io/u/SoulAssassin)\
**Post date:** [February 18, 2022, 2:19pm UTC](https://community.traefik.io/t/traefik-v2-and-unifi-controller/3231/5 "2022-02-18T14:19:41Z")

</div>

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

```auto
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"

```

---

<div class="post-metadata">

**Author:** ![SoulAssassin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/soulassassin/32/4409_2.png) [@SoulAssassin](https://community.traefik.io/u/SoulAssassin)\
**Post date:** [February 18, 2022, 2:36pm UTC](https://community.traefik.io/t/traefik-v2-and-unifi-controller/3231/6 "2022-02-18T14:36:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![alallier](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/alallier/32/1206_2.png) [@alallier](https://community.traefik.io/u/alallier)\
**Post date:** [February 18, 2022, 2:49pm UTC](https://community.traefik.io/t/traefik-v2-and-unifi-controller/3231/7 "2022-02-18T14:49:05Z")

</div>

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

> **[Unifi Controller in Docker on AWS/cloud](https://alexanderlallier.medium.com/unifi-controller-in-docker-on-aws-cloud-e4f87415a384)**
>
> Are you considering buying a Unifi Hardware Controller? Explore whether that makes sense and see how easy it is to deploy to the cloud.

---

<div class="post-metadata">

**Author:** ![SoulAssassin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/soulassassin/32/4409_2.png) [@SoulAssassin](https://community.traefik.io/u/SoulAssassin)\
**Post date:** [February 18, 2022, 2:53pm UTC](https://community.traefik.io/t/traefik-v2-and-unifi-controller/3231/8 "2022-02-18T14:53:30Z")

</div>

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