Setup Mautic on context-path, Updating to symfony/http-foundation 5.2+ (X_FORWARDED_PREFIX)

Your software
My Mautic version is: 4.4.0
My PHP version is: 7.4.6 (cli)
My Database type and version is: MariaDB 10.9.3
My nginx version: 1.19.8
My Setup: Installation on a Kubernetes Cluster. Mautic fpm < nginx < Istio VirtualService < …

Your problem
My problem is: While trying to make Mautic available on a context-path, e.g. (server.com/my/mautic/path) I could find any working solution. Tried almost everything found in this forum, setting Trusted Proxy, symfonys requst context base url / path etc. different rewrite Rules on nginx etc…

Then I found that with symfony/http-foundation 5.2+ the Request.php class supports a new HEADER (X_FORWARDED_PREFIX). Exactly what I was looking for. For a quick&dirty test I just overrode the relevant symfony class files (Request.php, InputBag.php, ParameterBag.php, HeaderUtils.php). Making some explorative tests with mautic it looks like to be a valid solution. Also because I think that Mautic will by default change the symfony deps to 5.2+ at some point in future.

Next I would like to update the http-foundation dep in a clean way with composer or so but do not have any experience yet.

Do you think it is a viable option? Any tipps on how to cleanly update the http-foundation dep. Do I have to builda custom mautic release? Are there any autom. test that would help to ensure mautic 4.4 works well with http-foundation 5.2+

Thanks for any hints / thoughts on this topic! It’s greatly appreciated,
Andreas

Hi, that’s why we work on the Matuic 5. So we could upgrade to Symfony 5+. It required some refactoring which is mainly done. The one remaining is converting all PHP templates to TWIG which is ongoing. See An update on the Mautic 5 release schedule

1 Like

Thanks @escopecz for confirming future availability of symfony 5.2 and the desired feature (FORWARDED_PREFIX)!

One thing we are facing is that while requesting service.tld/my/mautic/PUBLICPAGE1 the call ends up in a redirect loop. According to the PublicController::indexAction it is because of a mismatch check. (generatedURL vs. Request URI). So requestURI is /PUBLICPAGE1 but the generated URL is /my/mautic/PUBLICPAGE1. In this case the indexAction enforces a 301 redirect to the generated URL.

I have not checked if this happens on Mautic 5 as well. According to the indexAction-Code it looks like it is possible to set an request attribute (ignore_mismatch = 1) in order to prevent the redirection.

Has anybody a hint how to configure it globally? Looks like it is possible to append as query-Parameter, but I hope there is a better solution…

Thanks
Andreas