How to update Mautic when using a reverse proxy in front?

I’ve recently tried to update from Mautic 3.2.5 to 3.3.3. Before doing such things i always make a snapshot from the VM so i can easily rollback.
When i start the update using the WebGUI is seem to run good until the very last step where it hangs forever:

I know this is not what you asked, but I suggest to update by command line. It gives you lot better info about what the issue is.

Well, if it needs to be done that way… or at least if that works.

So, i now did:

php bin/console mautic:update:find
Version 3.3.3 von Mautic ist zum Download bereit. Weitere Informationen finden Sie hier: https://github.com/mautic/mautic/releases/tag/3.3.3.
Verwenden Sie 'php bin/console mautic:update:apply' auf der Kommandozeile um zu aktualisiern.

php bin/console mautic:update:apply
Sind Sie sicher, dass Sie Mautic  zur neuesten Version aktualisieren möchten? y
Step    5 [----->----------------------] Cache löschen

<warning>IMPORTANT: Run the same command again with --finish. For example 'php bin/console mautic:update:apply --finish'</warning>

php bin/console mautic:update:apply --finish
Step    3 [============================] Erfolg! Sie verwenden nun Mautic 3.3.3.

And the result is:

The site is currently offline due to encountering an error. If the problem persists, please contact the system administrator.

:frowning:

This is inside var/logs/mautic_prod-2021-06-23.php:

[2021-06-23 16:09:49] mautic.CRITICAL: Uncaught PHP Exception Symfony\Component\Filesystem\Exception\IOException: "Unable to write to the "/systems/mautic/htdocs/var/cache/prod" directory." at /mautic/htdocs/vendor/symfony/filesystem/Filesystem.php line 681 {"exception":"[object] (Symfony\\Component\\Filesystem\\Exception\\IOException(code: 0): Unable to write to the \"/mautic/htdocs/var/cache/prod\" directory. at /mautic/htdocs/vendor/symfony/filesystem/Filesystem.php:681)"} []
[2021-06-23 16:09:49] mautic.ERROR: Symfony\Component\Filesystem\Exception\IOException: Unable to write to the "/mautic/htdocs/var/cache/prod" directory. - in file /mautic/htdocs/vendor/symfony/filesystem/Filesystem.php - at line 681 [] []

I think it’s because i did it as root, as i cannot su to the www-data user (has no shell set).
After doing a

chown -R www-data:www-data /mautic/htdocs/var

I seem to load, but then gave a “Sad Mac” icon with:

ERR_TOO_MANY_REDIRECTS

I finally found out that this is because the index.php was replaced by a default one during the update and for our setup i need this file to contain an extra line, to have it work behing our reverse-proxy:

use function Stack\run;

ErrorHandler::register('prod');

# needed to work behind a reverse proxy
$_SERVER['HTTPS'] = 'on';

run((new MiddlewareBuilder(new AppKernel('prod', false)))->resolve());
~

When i re-add this line, i can use Mautic again. I guess this also happens when i do the Web-Based upgrade.

In our setup we have Internet —https—> [nginx Reverseproxy] —http—> [Mautic Webserver]

2 Likes