Quick Start: LDAP

how to configure ldap based on traefik

Quick Start: LDAP

If you want to use bitnamic/openldap, please follow this Quick Start: LDAP by Bitnami.

Prerequisite

OR

Note: If using HTTP, remove the tls: {} in dynamic configuration.

Preparation

compose.yml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
services:
    ldap:
        image: osixia/openldap
        restart: always
        environment:
            - LDAP_ORGANISATION=Chaos Inc.
            # if LDAP_DOMAIN=chaos.io, the login DN will be "cn=admin,dc=chaos,dc=io"
            # LDAP_DOMAIN default value is "example.org"
            # so default login DN is "cn=admin,dc=example,dc=org"
            - LDAP_DOMAIN=chaos.io
            - LDAP_ADMIN_PASSWORD=secret
        volumes:
            - ldap:/var/lib/ldap
            - slapd:/etc/ldap/slapd.d
        networks:
            - traefik-net

    ldapadmin:
        image: osixia/phpldapadmin
        restart: always
        environment:
            - PHPLDAPADMIN_LDAP_HOSTS=ldap
            # if configure https by traefik, you need to configure the following two lines
            # if not, remove them
            - VIRTUAL_HOST=ldap.x.internal
            - PHPLDAPADMIN_HTTPS=false
        networks:
            - traefik-net
volumes:
    ldap:
    slapd:

networks:
    traefik-net:
        external: true

ldap.yml in dir dynamic-conf

You should touch ldap.yml in traefik dir dynamic-conf.

For much more information, please reference the Prerequisite.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
http:
    routers:
        ldap:
            rule: "Host(`ldap.x.internal`)"
            service: "ldap"
            tls: { }

    services:
        ldap:
            loadBalancer:
                servers:
                    -   url: "http://ldapadmin"

DNS Configuration

Configure your DNS or modify your hosts file:

  • For Unix-like systems: Edit /etc/hosts
  • For Windows: Edit C:\Windows\System32\drivers\etc\hosts

Add the following line:

1
127.0.0.1 ldap.x.internal

Run

1
2
3
4
docker compose up -d
# Alternative commands:
# docker compose -p ldap up -d
# docker compose -f ./compose.yml -p ldap up -d

Access: https://ldap.x.internal