准备工作
mkdir -p /opt/openldap
cd /opt/openldap
vim docker-compose.yml
修改成自己的内容,包含域名、密码和邮箱,然后复制到docker-compose文件中
#docker-compose.yml
version: '2'
services:
openldap:
image: osixia/openldap:1.5.0
container_name: openldap
restart: always
environment:
LDAP_LOG_LEVEL: "256"
LDAP_ORGANISATION: "您的组织名称"
LDAP_DOMAIN: "open.com"
LDAP_BASE_DN: ""
LDAP_ADMIN_PASSWORD: "Nidemima"
LDAP_CONFIG_PASSWORD: "config"
LDAP_READONLY_USER: "false"
#LDAP_READONLY_USER_USERNAME: "readonly"
#LDAP_READONLY_USER_PASSWORD: "readonly"
LDAP_RFC2307BIS_SCHEMA: "false"
LDAP_BACKEND: "mdb"
LDAP_TLS: "true"
LDAP_TLS_CRT_FILENAME: "open.com.pem"#证书
LDAP_TLS_KEY_FILENAME: "open.com.key"
#LDAP_TLS_DH_PARAM_FILENAME: "dhparam.pem"
#LDAP_TLS_CA_CRT_FILENAME: "ca.crt"
LDAP_TLS_ENFORCE: "false"
LDAP_TLS_CIPHER_SUITE: "SECURE256:-VERS-SSL3.0"
LDAP_TLS_VERIFY_CLIENT: "demand"
LDAP_REPLICATION: "false"
#LDAP_REPLICATION_CONFIG_SYNCPROV: 'binddn="cn=admin,cn=config" bindmethod=simple credentials="$$LDAP_CONFIG_PASSWORD" searchbase="cn=config" type=refreshAndPersist retry="60 +" timeout=1 starttls=critical'
#LDAP_REPLICATION_DB_SYNCPROV: 'binddn="cn=admin,$$LDAP_BASE_DN" bindmethod=simple credentials="$$LDAP_ADMIN_PASSWORD" searchbase="$$LDAP_BASE_DN" type=refreshAndPersist interval=00:00:00:10 retry="60 +" timeout=1 starttls=critical'
#LDAP_REPLICATION_HOSTS: "#PYTHON2BASH:['ldap://ldap.example.org','ldap://ldap2.example.org']"
KEEP_EXISTING_CONFIG: "false"
LDAP_REMOVE_CONFIG_AFTER_SETUP: "true"
LDAP_SSL_HELPER_PREFIX: "ldap"
tty: true
stdin_open: true
volumes:
- /opt/openldap/data:/var/lib/ldap
- /opt/openldap/config:/etc/ldap/slapd.d
- /root/openart/nginx/ssl/:/container/service/lapd/assets/certs/
ports:
- "389:389"
- "636:636"
# For replication to work correctly, domainname and hostname must be
# set correctly so that "hostname"."domainname" equates to the
# fully-qualified domain name for the host.
domainname: "open.com"
hostname: "ldap-server"
phpldapadmin:
image: osixia/phpldapadmin:latest
container_name: phpldapadmin
restart: always
environment:
PHPLDAPADMIN_LDAP_HOSTS: "openldap"
PHPLDAPADMIN_HTTPS: "false"
ports:
- "50081:80"
depends_on:
- openldap
self-service-password:
container_name: self-service-password
image: tiredofit/self-service-password:latest
restart: always
ports:
- "50080:80"
environment:
- LDAP_SERVER=ldap://openldap:389
- LDAP_BINDDN=cn=admin,dc=open,dc=com
- LDAP_BINDPASS=Nidemima
- LDAP_BASE_SEARCH=dc=open,dc=com
- MAIL_FROM=it@open.com
- MAIL_FROM_NAME=账号自助服务平台
- SMTP_DEBUG=0
- SMTP_HOST=smtp.qiye.aliyun.com
- SMTP_USER=it@open.com
- SMTP_PASS=jYda52VZ8Ftw1111
- SMTP_PORT=465
- SMTP_SECURE_TYPE=ssl
- SMTP_AUTH_ON=true
- NOTIFY_ON_CHANGE=true
volumes:
- /etc/localtime:/etc/localtime
- /opt/openldap/self-service-password/htdocs:/www/ssp
- /opt/openldap/self-service-password/logs:/www/logs
deploy:
resources:
limits:
memory: 2G
reservations:
memory: 512M
启动容器
docker-compose up -d
查看容器启动情况
docker ps -a
这里有个小问题,需要在重置密码的地方改一下,不然收到重置密码的邮件的链接是不正确的
vim /opt/openldap/self-service-password/htdocs/conf/config.inc.php
修改约244行
改为
$reset_url = "http://您的域名+端口" ;
至此,搭建彻底完成!
访问测试
http://您的域名或ip:50080 访问自助密码管理平台
http://您的域名或ip:50081 访问LDAP管理平台