Skip to content

Bug & Request: FrankenPHP/Caddy Host Routing causes 502 Bad Gateway when behind reverse proxy (NPM/Cloudflare) #477

Description

@ljc2221788-commits

Is there an existing issue for this?

  • I have searched the existing issues

Environment

- OS:Ubuntu 22.04.5 LTS
- PHP:system default
- LDAP Server:openldap

PLA Code

Docker hub

PLA Version

2.3.11

Current Behavior

When deploying the phpldapadmin container behind a reverse proxy (e.g., Nginx Proxy Manager or Cloudflare) with SSL termination, requests forwarded to the container result in a 502 Bad Gateway error on the reverse proxy.

This is because the internal FrankenPHP/Caddy web server performs strict host header checks/routing. When the external domain name passed in the Host header does not match the internal SERVER_NAME / Caddy route rules, Caddy rejects or ignores the connection, causing NPM to report a 502 error. However, accessing the container locally via curl http://127.0.0.1:8080 returns HTTP 200 OK without issues.

Expected Behavior

  1. The container should allow requests with arbitrary or external Host headers by default (catch-all host routing like :80 or :8080), allowing seamless integration with external reverse proxies (NPM, Traefik, Caddy, Cloudflare).
  2. Alternatively, provide an environment variable (e.g., SERVER_NAME=* or a flag to disable strict host matching) so users can easily bypass strict host header checks when running behind a proxy.

Steps To Reproduce

  1. In an environment with an external reverse proxy (e.g., Nginx Proxy Manager / Caddy) configured for HTTPS/SSL termination for ldap.example.com.
  2. Deploy the phpldapadmin container mapping port 8080 to the host network (e.g., app-net).
  3. Point the reverse proxy's upstream host/IP to phpldapadmin:8080.
  4. Access https://ldap.example.com from an external browser/client.
  5. See error: The reverse proxy returns 502 Bad Gateway because FrankenPHP/Caddy inside the container rejects the unrecognized external Host header.

Relevant log output

Anything else?

UI / UX Enhancement Request:
By the way, as a side suggestion for future releases, it would be awesome if the phpLDAPadmin Web UI could receive a modern face-lift/refresh to make the overall interface cleaner, more intuitive, and responsive on modern browsers.

Thanks again to the maintainers for your time and efforts!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions