Add container-aware fallback to EndpointChecker#52
Merged
Conversation
When the public URL and 127.0.0.1 loopback both fail (common in Docker Compose stacks where PHP-FPM and the web server are separate containers), try DNS-resolvable service names before reporting failure. Candidates cover the major Drupal Docker stacks: nginx (Wodby), web (DDEV), apache/httpd, appserver (Lando), and webserver (generic). Only runs when /.dockerenv exists. DNS resolution filters to names that actually exist (~5 ms total), then probes only resolved hosts with the original Host header to avoid tripping trusted_host_patterns.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/.dockerenv)gethostbyname()to filter candidates (~5 ms total), then probes only resolved hosts via HTTPHostheader to avoid tripping Drupal'strusted_host_patternsupgradeOnLoopbackSuccess()Context
In Docker Compose stacks where PHP-FPM and the web server run in separate containers (Wodby, DDEV, Lando, custom stacks), neither the public hostname nor
127.0.0.1is reachable from the PHP container. The public hostname resolves only on the Docker host (via Traefik), and127.0.0.1is the PHP container itself (no web server). This causedEndpointCheckerto always report failure in containerized environments, even thoughrl.phpworks fine for browsers.The fix probes common web-server service names that Docker's internal DNS resolves:
nginx(Wodby/docker4drupal, Lagoon)web(DDEV, Platform.sh local)apache,httpd(generic Apache stacks)appserver(Lando)webserver(generic)Test plan
php -lcleandrush evclears state, visits status report, shows green/.dockerenvcheck)Ref #50