Skip to content

Add container-aware fallback to EndpointChecker#52

Merged
jjroelofs merged 1 commit into
1.xfrom
jur/1.x/#50-container-aware-loopback-fallback
May 7, 2026
Merged

Add container-aware fallback to EndpointChecker#52
jjroelofs merged 1 commit into
1.xfrom
jur/1.x/#50-container-aware-loopback-fallback

Conversation

@jjroelofs
Copy link
Copy Markdown
Contributor

Summary

  • When the public URL probe and 127.0.0.1 loopback both fail, try DNS-resolvable Docker Compose service names before reporting failure
  • Only activates inside containers (checks for /.dockerenv)
  • Uses gethostbyname() to filter candidates (~5 ms total), then probes only resolved hosts via HTTP
  • Sends the original Host header to avoid tripping Drupal's trusted_host_patterns
  • Extracts duplicate loopback-success logic into upgradeOnLoopbackSuccess()

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.1 is reachable from the PHP container. The public hostname resolves only on the Docker host (via Traefik), and 127.0.0.1 is the PHP container itself (no web server). This caused EndpointChecker to always report failure in containerized environments, even though rl.php works 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 -l clean
  • Tested in Wodby stack: drush ev clears state, visits status report, shows green
  • Verified DNS scan adds ~5 ms, not seconds
  • Non-container environments skip the fallback entirely (/.dockerenv check)

Ref #50

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.
@jjroelofs jjroelofs merged commit 5cbe10d into 1.x May 7, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant