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

**URL:** <https://forum.mautic.org/t/how-to-update-mautic-when-using-a-reverse-proxy-in-front/19923>\
**Category:** Mautic 3 - Install/Upgrade Support\
**Created:** [June 21, 2021, 8:40am UTC](https://forum.mautic.org/t/how-to-update-mautic-when-using-a-reverse-proxy-in-front/19923 "2021-06-21T08:40:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![imog](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imog/32/3813_2.png) [@imog](https://forum.mautic.org/u/imog)\
**Post date:** [June 21, 2021, 8:40am UTC](https://forum.mautic.org/t/how-to-update-mautic-when-using-a-reverse-proxy-in-front/19923/1 "2021-06-21T08:40:30Z")

</div>

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:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/e/e7e1f4d579bf88b8acf5d0384e744f9b0d9d71d5.png)

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [June 22, 2021, 8:44am UTC](https://forum.mautic.org/t/how-to-update-mautic-when-using-a-reverse-proxy-in-front/19923/2 "2021-06-22T08:44:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![imog](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imog/32/3813_2.png) [@imog](https://forum.mautic.org/u/imog)\
**Post date:** [June 23, 2021, 2:00pm UTC](https://forum.mautic.org/t/how-to-update-mautic-when-using-a-reverse-proxy-in-front/19923/3 "2021-06-23T14:00:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![imog](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imog/32/3813_2.png) [@imog](https://forum.mautic.org/u/imog)\
**Post date:** [June 23, 2021, 2:07pm UTC](https://forum.mautic.org/t/how-to-update-mautic-when-using-a-reverse-proxy-in-front/19923/4 "2021-06-23T14:07:58Z")

</div>

So, i now did:

```auto
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.

☹

This is inside var/logs/mautic\_prod-2021-06-23.php:

```auto
[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

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

```

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

```auto
ERR_TOO_MANY_REDIRECTS

```

---

<div class="post-metadata">

**Author:** ![imog](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/imog/32/3813_2.png) [@imog](https://forum.mautic.org/u/imog)\
**Post date:** [June 23, 2021, 2:17pm UTC](https://forum.mautic.org/t/how-to-update-mautic-when-using-a-reverse-proxy-in-front/19923/5 "2021-06-23T14:17:24Z")

</div>

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:

```auto
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]

---

<div class="post-metadata">

**Author:** ![csaeum](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/csaeum/32/151_2.png) [@csaeum](https://forum.mautic.org/u/csaeum)\
**Post date:** [July 6, 2024, 2:09pm UTC](https://forum.mautic.org/t/how-to-update-mautic-when-using-a-reverse-proxy-in-front/19923/6 "2024-07-06T14:09:22Z")

</div>

I have a similar problem. What did you do so that the forms are delivered with https, for example, when Mautic runs as http behind Traefik?

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [September 4, 2024, 9:53am UTC](https://forum.mautic.org/t/how-to-update-mautic-when-using-a-reverse-proxy-in-front/19923/7 "2024-09-04T09:53:23Z")

</div>

The proxy rewrites everything and the traffic to the outside world is done via https.
