phpmentors/proxy-url-rewrite-bundle
Symfony bundle that rewrites request URLs behind reverse proxies using forwarded headers, helping PHP applications generate correct absolute links, redirects, and assets when served through load balancers or proxy servers.
redirect_uri, password-reset and notification links) using the internal scheme/host instead of the public-facing one. The decision it informs is whether to solve that in the app framework, at the edge (nginx proxy_redirect, X-Forwarded-Prefix), or via a library — and this package is a data point for the "library" option./app behind a gateway) or a per-tenant hostname, this informs whether URL generation should be config-driven and proxy-aware from day one rather than hardcoded.TrustProxies + URL::forceScheme/forceRootUrl) versus adopting a cross-framework convention. For a Laravel-first product, this specific package is not adoptable — the decision it supports is don't vendor it, and instead codify the equivalent behavior in Laravel middleware.absolute_url() call site.Consider it when:
Look elsewhere when:
TrustProxies middleware plus URL::forceScheme() / URL::forceRootUrl(); this is first-party, maintained, and covers the same ground. Adopting a Symfony bundle here is not feasible.Request::setTrustedProxies() and trusted-header handling in framework.trusted_proxies/trusted_headers generally solve this without a third-party bundle.X-Forwarded-Proto/Host/Prefix, proxy_redirect) is often the lower-total-cost fix and keeps the application ignorant of its deployment topology.Forwarded as well as X-Forwarded-*, port and path-prefix rewriting, and trusted-proxy allowlists; if any are missing, an in-house implementation will be more predictable than patching an abandoned bundle.For executives (one paragraph): We evaluated a small open-source component for a real but unglamorous problem — keeping links, redirects, and login callbacks correct when our application runs behind a load balancer, CDN, or gateway. Getting this wrong produces broken password-reset emails, failing SSO/OAuth logins, and SEO-visible canonical URL errors, and it is a classic cause of "works in staging, broken in production" incidents during infrastructure migrations. The component itself is not a viable dependency for us: it is Symfony-only, last released in 2018, has no downstream users, and carries no maintenance commitment. Recommendation: do not adopt; budget roughly one to two engineering days to implement the equivalent behavior natively in our framework's middleware and document the trusted-proxy contract as part of the deployment standard. This captures the benefit at lower long-term risk and avoids a fork we would have to maintain indefinitely.
For engineering leads: The problem is legitimate and the pattern is worth codifying: derive the externally visible scheme, host, port, and path prefix from trusted forwarded headers, and ensure all generated absolute URLs honor them — not just request introspection. The bundle is a useful reference implementation for that logic and a checklist of edge cases (path prefixes, non-default ports, redirect base URLs). It is not a dependency: no PHP 8.x/Symfony 6+ support, no tests or CI we can rely on, no release cadence. Concretely — in Laravel, implement via TrustProxies plus forceScheme/forceRootUrl and cover it with tests that assert generated URLs under simulated X-Forwarded-* headers; in Symfony, prefer native trusted-proxy configuration. Either way, constrain the trusted-proxy allowlist explicitly — misconfigured trust of forwarded headers is a host-header-injection and cache-poisoning vector, and that risk is ours to own whether we write the code or import it.
How can I help you explore Laravel packages today?