I think that I have misconfiguration issue in my environment, and I would like to hear your opinions about it. Advice or help to solve it would be more than welcome.
Description: I have problem with accessing to LDAP Admin using jwilder/nginx-proxy container over the virtual hostname while accessing through real linux hostname with an exposed port works fine. Access is with HTTPS using valid wildcard certificate.
Environment: I am running docker on linux (CentOS 7) and I want to setup one docker container with jwilder/nginx-proxy and additional two docker containers: one for openLdap, second one for phpLdapAdmin. So access to my ldapadmin will be through nginx, without exposing ports.
Steps done so far:
1. Create container - nginx proxy
docker run -d -p 80:80 -p 443:443 \
-v /home/admin/nginx/certs:/etc/nginx/certs \
-v /var/run/docker.sock:/tmp/docker.sock:ro \
--name proxy \
jwilder/nginx-proxy
2. Create container - ldap
docker run --name ldap -p 636:636 \
-v /home/admin/nginx/certs:/container/service/slapd/assets/certs \
-v /data/slapd/database:/var/lib/ldap \
-v /data/slapd/config:/etc/ldap/slapd.d \
--hostname ldap.company.com \
--add-host=ldap.company.com:192.168.168.168 \
--env LDAP_ORGANISATION='Company ltd' \
--env LDAP_DOMAIN='company.com' \
--env LDAP_ADMIN_PASSWORD='Password' \
--detach osixia/openldap:1.2.2 \
Instead of "192.168.168.168" is my real public IP address
Then successfully search for LDAP
docker exec ldap \
ldapsearch -x -H ldap://ldap.company.com \
-b dc=company,dc=com \
-D "cn=admin,dc=company,dc=com" \
-w Password\
3. Create container phpldapadmin
docker run \
--name ldapadmin \
--env PHPLDAPADMIN_LDAP_HOSTS=ldap.company.com \
--expose 389 \
-e VIRTUAL_HOST=ldap.company.com \
-e VIRTUAL_PORT=389 \
--volume /home/admin/nginx/certs:/container/service/phpldapadmin/assets/apache2/certs \
--env PHPLDAPADMIN_HTTPS_CRT_FILENAME=ldap.company.com.crt \
--env PHPLDAPADMIN_HTTPS_KEY_FILENAME=ldap.company.com.key \
--env PHPLDAPADMIN_HTTPS_CA_CRT_FILENAME=ldap.company.com.crt \
--detach osixia/phpldapadmin:0.7.2
And finally restart nginx proxy container to automatically add ldap and ldapadmin to nginx configuration.
docker restart proxy
Then I get this exposed ports:
IMAGE PORTS NAMES
osixia/phpldapadmin:0.7.2 80/tcp, 389/tcp, 443/tcp ldapadmin
osixia/openldap:1.2.2 389/tcp, 0.0.0.0:636->636/tcp ldap
Now comes the strange part, hostname of my Linux server is dev.company.com with some public address, and I can access my ldapadmin with https://dev.company.com:6443, but I can not access through URL: ldap.company.com, without exposing ports. I can not ping ldap.company.com.key on Linux host itself.
Note: I have done the same thing for Jenkins:
docker run -d --rm -u root -v /var/run/docker.sock:/var/run/docker.sock -v jenkins-data:/var/jenkins_home -v "$HOME":/home -e VIRTUAL_HOST=jenkins.company.com -e VIRTUAL_PORT=8080 --name nj jenkins
and for artifactory:
docker run --name artifact -d -v /var/opt/jfrog/artifactory:/var/opt/jfrog/artifactory -e VIRTUAL_HOST=artifactory.company.com -e VIRTUAL_PORT=8081 artifactory-oss
and for both of these two i have URL's which are pingable, they return my public IP address and I successfully access them through browser: jenkins.company.com and artifactory.company.com
I can not ping ldap.company.com.key on Linux host itself.
First of all, you can check the logs of the
jwilder/nginx-proxy
if it actually receives any requests:But if you can't even ping
ldap.company.com
, then probably the domain can't be resolved to an IP address, because there is no DNS record for it. You can test this with:If the domain can't be resolved, then create a DNS A record in the
company.com
DNS server that pointsldap.company.com
to the public IP address of your host.Or you can test if everything works already before, if you just make the PHPLDAPAdmin requests to the public IP address of your host rather than the
ldap.company.com
domain.