mirror of
https://github.com/lldap/lldap.git
synced 2026-04-25 08:15:52 +03:00
[GH-ISSUE #700] Bug: Listening to an address other than 127.0.0.1/32 or 0.0.0.0/32 breaks docker health checks #248
Labels
No labels
backend
blocked
bug
cleanup
dependencies
docker
documentation
duplicate
enhancement
enhancement
frontend
github_actions
good first issue
help wanted
help wanted
integration
invalid
ldap
pull-request
question
rust
rust
tests
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/lldap-lldap#248
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @TheRealGramdalf on GitHub (Oct 6, 2023).
Original GitHub issue: https://github.com/lldap/lldap/issues/700
Forgive me if this isn't possible/within the scope of LLDAP. I tried to look through the code briefly to see whether I could figure it out on my own, but I'm not familiar enough with rust to find it easily.
The issue:
When binding the LDAP IP address to a specific IPv4 address (
LLDAP_LDAP_HOST = "192.168.2.2", which is technically192.168.2.2/32- unless LLDAP does something weird), docker health checks fail.Why it happens:
It's simple in nature: The docker health check attempts to reach the LDAP api on
127.0.0.1/32, but gets refused - LDAP is listening on192.168.2.2/32. Thus, it's request is refused.The solution:
Unless it is a case of user error, I see three ways to resolve this:
127.0.0.1/32when dockerizedLLDAP_LDAP_HOSTaddress for docker healthchecksAgain, forgive me if I'm incorrect - I wasn't able to find any information in the issues, readme, or code regarding this.
@TheRealGramdalf commented on GitHub (Oct 6, 2023):
For now I'm using
0.0.0.0as my listen address, but I would prefer to listen to an address managed by my firewall if possible. I can provide more information about my setup if needed.@nitnelave commented on GitHub (Oct 6, 2023):
Out of curiosity, would something like https://github.com/lldap/lldap/issues/701 help?
Otherwise, I propose another solution: make the healthcheck target configurable. That way you can choose yourself between options 2 or 3.
@martadinata666 commented on GitHub (Oct 6, 2023):
Adding to this, manually trigger healthcheck, somehow it don't read
LLDAP_LDAP_HOSTparameter correctly or as the port read correctly. 🤔 Accidentally hardcoded tolocalhost?@nitnelave commented on GitHub (Oct 6, 2023):
ldap_hostis somewhat misnamed, it's the listen address.Healthcheck is hardcoded to listen to localhost.
@TheRealGramdalf commented on GitHub (Oct 6, 2023):
My two cents on this and #701 :
0.0.0.0:portin theldap_hostconfiguration could be considered more complex, as it could lead to a situation in which a user isn't certain which port is actually being used - they may be unsure whether:0.0.0.0:porttakes priority overldap_portldap_host/portvs0.0.0.0:port) would be the best.0.0.0.0:port. Using only that value would require deprecation ofldap_port, which could be tricky.TL;DR
ldap_portin favor ofldap_host = 0.0.0.0:portThings of note:
touch /var/run/lldap.sock) is left.LLDAP_IS_DOCKERIZEDor something to that effect. If the variable is defined (At all! Even if a user defines their own value for whatever reason), lldap assumes it is running within docker, and creates the unix socket for docker healthchecks.I'm sort of playing devils advocate here, but I also believe this would be the simplest to implement, maintain, and be transparent to the user. IMHO, users shouldn't have to configure docker health checks - they should just work. But by any means, I'm open to suggestions. It's not my project, after all :)
Edit: Sorry for the double notification, the issue didn't tag properly. Not sure why that is.
@Zepmann commented on GitHub (Oct 6, 2023):
@TheRealGramdalf
Just because lldap would support unix sockets would not have to make usage harder. Using it is optional. If you are afraid of it confusing new users, leave examples out of the default configuration file and only note them in documentation (for advanced users/usage). Hell, you can even put it on a separate documentation page dedicated to unix sockets and slap a big warning on top of it that it is not necessary for normal operations.
If you wanted simple and not scare away users, you can also remove LDAPS support. TLS is not simple for the uninitiated. I would even wager it is more complex compared to unix sockets. Strictly speaking, it is not necessary for LDAP support, and LDAPS support can also be added through other means (e.g. a TLS wrapper such as stunnel or a reverse proxy such as HAProxy in TCP mode).
Not everyone runs lldap in docker. Unix sockets are useful if docker is not used. With docker, TCP connections make more sense since they are easier to manage in, through and outside of docker.
@nitnelave commented on GitHub (Oct 6, 2023):
Hey, thanks for your opinions on the matter! That gave me food for thought. Here's what I'm currently thinking:
What I'd like to propose is:
ldap_host/ldap_port/ldaps_port/http_host/http_port, they are not deprecated. But in the config, they become optional (though the default template has values for them).ldap_bind_socket_addresses,ldaps_bind_socket_addresses,http_bind_socket_addresses. These keys are lists (TOML lists) so the parsing is clear. These are in the formatIP:portwith a mandatory port orunix@path*_bind_socket_addressesvariable and a*_hostor*_port, that's an error and the server doesn't start. If you set nothing, use the defaults for host and port. In addition, if you set theldap_bind_socket_addressesand you enable LDAPS, we'll require aldaps_bind_socket_addresses.The new config values can be documented in the config template, but as advanced features. Since it's marked as an advanced and optional feature, we can mention the unix sockets and the fact that they are incompatible with
*_host/*_port. No integration example will be recommending it, so if you got to them it's probably that you read the docs.Along those lines, we can similarly add an advanced
[healthcheck]section, withldap_socket_address/ldaps_socket_address/http_socket_addressfor those who want to tune everything to their liking.I don't think that we should try to detect docker or do anything specific in the container. That, for me, is more essential to keeping the project simple.
What do you think about this proposal? It's fairly broad, and thus covers both #700 and #701.
@Zepmann commented on GitHub (Oct 7, 2023):
@nitnelave
That's a good proposal. I agree that unix sockets are an advanced topic, so they should not be mentioned in integration examples in the documentation.
Maybe over time you can also consider adding these socket file options for completeness sake? I would not make them part of this request since it is complex enough as it is, but it could be put on a roadmap.
An idea for implementation:
Every value is optional, but at least one value should be specified if
unix:is used. Usingunix:to indicate a unix socket address with options does not break backwards compatibility in configuration files ifunix@is implemented first.@TheRealGramdalf commented on GitHub (Oct 7, 2023):
I agree, that's partly why I was hesitant to push for deprecating an option. I think this is probably the best path forward
One thing to note here: I'm not sure if this is the case (I'm using Portainer, so logs are somewhat weird for me), but it would be good to make sure that these messages are displayed regardless of the debug level - I don't think a user should have to enable
debug = trueto see why their container doesn't start up.@nioc commented on GitHub (Apr 14, 2025):
Hello, as a new user, I'm encountering the same problem as the original subject: I'm exposing the 17170/UI port on a
proxynetwork used by a HAProxy and the 3890/ldap port on another networkldapaccessible only to Authelia (LLDAP_LDAP_HOST: 172.30.0.2 which is on this second network).Would it be possible to tell the healthcheck what ldap_host value to use?
For now, I disabled the healthcheck...
Here is my docker-compose.yml:
@nitnelave commented on GitHub (Apr 15, 2025):
The health check can take pretty much all the same options as lldap, so you can add cli flags or env variables to affect its behavior. You just need to copy the health check command from the docker file (something like
lldap check_health) and add the flags you want@nioc commented on GitHub (Apr 15, 2025):
I tried some commands, but healthcheck never worked...
I look at the code (disclaimer: I do not know Rust), and when I read this:
github.com/lldap/lldap@1f89059c84/server/src/main.rs (L254)github.com/lldap/lldap@1f89059c84/server/src/healthcheck.rs (L73-L75)It seems I can override whatever, healthcheck will still try to connect at
localhost.@nitnelave commented on GitHub (Apr 15, 2025):
Ah, yes, sorry for misleading you. I guess that's not implemented, then.
@fsdrw08 commented on GitHub (Apr 21, 2025):
currently, lldap healthcheck command can only detect the instance which running and listen on localhost
@sdwilsh commented on GitHub (Oct 11, 2025):
@nitnelave, would you accept a PR to have the healthcheck use the configured address instead of a hardcoded
localhostas you suggested in https://github.com/lldap/lldap/issues/700#issuecomment-2803582451? I think that meets the requirements of not breaking existing configurations for the default config nor for those who might have set an IP address.@nitnelave commented on GitHub (Oct 11, 2025):
I would accept a PR adding arguments to override the health check target addresses, yes