Mautic Community Forums

Mautic Failed after updating CORS Settings

Your software
My Mautic version is: 2.16.2
My PHP version is: 7.2.31

Your problem
My problem is: Well I have just started using mautic and honestly the first impression is that its indeed a very impressive piece of software. Kudos to the developer team since till now I think the attention to detail is immense in developing the software.

Anyhow, when I was setting up my CORS settings I think I did enter *rigpl.com in settings and applied the settings which has caused my instance to crash.

Now I think the developers should disallow such fields to be updated into the database and hence I think its a bug atleast for a newbie like me. I am also enclosing the logs below which definitely show that the error is due to the *rigpl.com entry in the configuration.

Now since I cannot access the site from browser, I would like to know where can I remove this entry.

These errors are showing in the log:

[2020-05-22 10:44:05] mautic.ERROR: Symfony\Component\HttpKernel\Exception\BadRequestHttpException: Untrusted Host "ma.rigpl.com" - in file /var/www/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php - at line 120 [] []
[2020-05-22 16:14:06] mautic.WARNING: PHP Warning - preg_match(): Compilation failed: nothing to repeat at offset 0 - in file /var/www/mautic/app/bootstrap.php.cache - at line 945 {"host":"ma.rigpl.com","pattern":"{*rigpl.com}i"} []
[2020-05-22 16:14:06] mautic.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\BadRequestHttpException: "Untrusted Host "ma.rigpl.com"" at /var/www/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php line 120 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException(code: 0): Untrusted Host \"ma.rigpl.com\" at /var/www/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php:120, UnexpectedValueException(code: 0): Untrusted Host \"ma.rigpl.com\" at /var/www/mautic/app/bootstrap.php.cache:950)"} []
[2020-05-22 16:14:06] mautic.WARNING: PHP Warning - preg_match(): Compilation failed: nothing to repeat at offset 0 - in file /var/www/mautic/app/bootstrap.php.cache - at line 945 {"host":"ma.rigpl.com","pattern":"{*rigpl.com}i"} []
[2020-05-22 16:14:06] mautic.WARNING: PHP Warning - preg_match(): Compilation failed: nothing to repeat at offset 0 - in file /var/www/mautic/app/bootstrap.php.cache - at line 945 {"host":"ma.rigpl.com","pattern":"{*rigpl.com}i"} []
[2020-05-22 16:14:06] mautic.ERROR: Exception thrown when handling an exception (Symfony\Component\HttpKernel\Exception\BadRequestHttpException: Untrusted Host "ma.rigpl.com" at /var/www/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php line 120) {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException(code: 0): Untrusted Host \"ma.rigpl.com\" at /var/www/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php:120, UnexpectedValueException(code: 0): Untrusted Host \"ma.rigpl.com\" at /var/www/mautic/app/bootstrap.php.cache:950)"} []
[2020-05-22 16:14:06] mautic.ERROR: Symfony\Component\HttpKernel\Exception\BadRequestHttpException: Untrusted Host "ma.rigpl.com" - in file /var/www/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php - at line 120 [] []
[2020-05-22 10:46:11] mautic.WARNING: PHP Warning - preg_match(): Compilation failed: nothing to repeat at offset 0 - in file /var/www/mautic/app/bootstrap.php.cache - at line 945 {"host":"ma.rigpl.com","pattern":"{*rigpl.com}i"} []
[2020-05-22 10:46:11] mautic.ERROR: Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\BadRequestHttpException: "Untrusted Host "ma.rigpl.com"" at /var/www/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php line 120 {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException(code: 0): Untrusted Host \"ma.rigpl.com\" at /var/www/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php:120, UnexpectedValueException(code: 0): Untrusted Host \"ma.rigpl.com\" at /var/www/mautic/app/bootstrap.php.cache:950)"} []
[2020-05-22 10:46:11] mautic.WARNING: PHP Warning - preg_match(): Compilation failed: nothing to repeat at offset 0 - in file /var/www/mautic/app/bootstrap.php.cache - at line 945 {"host":"ma.rigpl.com","pattern":"{*rigpl.com}i"} []
[2020-05-22 10:46:11] mautic.WARNING: PHP Warning - preg_match(): Compilation failed: nothing to repeat at offset 0 - in file /var/www/mautic/app/bootstrap.php.cache - at line 945 {"host":"ma.rigpl.com","pattern":"{*rigpl.com}i"} []
[2020-05-22 10:46:11] mautic.ERROR: Exception thrown when handling an exception (Symfony\Component\HttpKernel\Exception\BadRequestHttpException: Untrusted Host "ma.rigpl.com" at /var/www/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php line 120) {"exception":"[object] (Symfony\\Component\\HttpKernel\\Exception\\BadRequestHttpException(code: 0): Untrusted Host \"ma.rigpl.com\" at /var/www/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php:120, UnexpectedValueException(code: 0): Untrusted Host \"ma.rigpl.com\" at /var/www/mautic/app/bootstrap.php.cache:950)"} []
[2020-05-22 10:46:11] mautic.ERROR: Symfony\Component\HttpKernel\Exception\BadRequestHttpException: Untrusted Host "ma.rigpl.com" - in file /var/www/mautic/vendor/symfony/http-kernel/EventListener/RouterListener.php - at line 120 [] []

Steps I have tried to fix the problem: I need to know the steps to resolve this error.

Github Issue#2355 Resolved this issue but I still strongly think that issue being closed should be revived since it basically locks out the users from the server.

The issue is resolved though.

This is by design, and Trusted Hosts is different than the allowed domains in the CORS Settings further down the page in Configuration > Basic Settings.

To limit which domains are allowed to embed the tracking pixel, all the domains and subdomains to be tracked (http and https, non-www and www) should be included in CORS settings. The Trusted Hosts is related to where Mautic is running behind a proxy such as a Load Balancer, which is not the case for most users.

Mautic should lock users out when the incorrect setting is entered in Trusted Hosts, as its a security setting. That’s why the Github issue was closed because the “problem” is due to user error, even though the documentation could probably be improved.