# Setup Mautic on context-path, Updating to symfony/http-foundation 5.2+ (X\_FORWARDED\_PREFIX)

**URL:** <https://forum.mautic.org/t/setup-mautic-on-context-path-updating-to-symfony-http-foundation-5-2-x-forwarded-prefix/25901>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [October 31, 2022, 1:28pm UTC](https://forum.mautic.org/t/setup-mautic-on-context-path-updating-to-symfony-http-foundation-5-2-x-forwarded-prefix/25901 "2022-10-31T13:28:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andkp80](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/andkp80/32/8549_2.png) [@andkp80](https://forum.mautic.org/u/andkp80)\
**Post date:** [October 31, 2022, 1:28pm UTC](https://forum.mautic.org/t/setup-mautic-on-context-path-updating-to-symfony-http-foundation-5-2-x-forwarded-prefix/25901/1 "2022-10-31T13:28:31Z")

</div>

**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](http://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

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [November 2, 2022, 10:16am UTC](https://forum.mautic.org/t/setup-mautic-on-context-path-updating-to-symfony-http-foundation-5-2-x-forwarded-prefix/25901/2 "2022-11-02T10:16:51Z")

</div>

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](https://www.mautic.org/blog/community/update-mautic-5-release-schedule)

---

<div class="post-metadata">

**Author:** ![andkp80](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/andkp80/32/8549_2.png) [@andkp80](https://forum.mautic.org/u/andkp80)\
**Post date:** [November 4, 2022, 9:59am UTC](https://forum.mautic.org/t/setup-mautic-on-context-path-updating-to-symfony-http-foundation-5-2-x-forwarded-prefix/25901/3 "2022-11-04T09:59:55Z")

</div>

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
