Your software
Server: Linux xxx 5.10.0-13-amd64 #1 SMP Debian 5.10.106-1 (2022-03-17) x86_64
My Mautic version is: 4.2.1 (upgraded from 4.0.x)
My PHP version is: 7.4.28
My Database type and version is: 10.5.15-MariaDB-0+deb11u1
Your problem
My problem is:
We have setup our Site-URL to “https://mautic.domain.com/”. This domain however isn’t always properly used. See this example:
I create a new segment mail, using a theme which utilizes {webview_url} and {tracking_pixel}.
I send an example to myself. The {webview_url} and {tracking_pixel} fields are correctly substituted by the Site-URL.
I send the actual e-mail. The {webview_url} and {tracking_pixel} fields are not correctly substituted by the Site-URL. They instead show a URL to https://10.10.x.x/.
The logs don’t show any issue. I have cleared the cache, both using ‘php bin/console cache:clear’ and ‘rm -rf var/cache/*’.
Also verified that my config/local.php site_url is set up correctly. In the database or the mautic folder I can find no reference to our internal IP address.
I would like to prevent having to do a clean install, is there any way to fix this issue? I recently upgraded to 4.2.1 but also had this issue in older versions. I’ve upgraded from 4.0.2.
Apparently Mautic doesn’t use the site_url in the configuration when sending out Segment mails. Instead, it’s uses the URL the admin is using to access Mautic and start the Segment mail (in my case, 10.10.x.x instead of mautic.domain.com). We are using our Mautic instance behind a reverse proxy. I’ll try to change it there so this proxy addresses the Mautic instance by it’s FQDN instead of IP-address.
EDIT: I can confirm this is the issue. My reverse proxy was accessing the Mautic instance on https://10.10.x.x/ instead of https://mautic.domain.com/). This causes Mautic to use that URL (instead of site_url specified in the configuration) for links in Segment mails. It doesn’t happen on sending examples, but when actually sending the e-mails the problem occurs. Now that I’ve changed my reverse proxy (by adding a manual entry for mautic.domain.com to 10.10.x.x) to access the Mautic instance on the FQDN-URL, the issue is resolved.
Hi @Milenco,
I think I am having the same issue as you. I am also using the Mautic instance behind a reverse proxy. But I don’t really understand your solution. Could you please explain again what exactly did you do in order to fix the problem? What do you mean by “adding a manual entry”? Thanks!
So, in my case, my reverse proxy is a Windows Server machine running IIS. The problem is that IIS is accessing Mautic through http://10.10.10.123 instead of http://mautic.domain.com. This URL is used in the webview_url and tracking_pixel shortcuts.
To prevent this, you need to have IIS access your Mautic instance through mautic.domain.com (instead of the IP directly). But, because mautic.domain.com translates to a public IP-address, your IIS instance needs to be tricked to access the DNS-name through it’s local IP-address. To do so, edit C:\Windows\system32\drivers\etc\hosts and add a line for mautic.domain.com which has Mautics local IP in it.
Hi @Milenco,
Thank you for your answer.
In my case, I’ve finally fixed my issue by adding $_SERVER[‘HTTP_HOST’] = ‘mautic.domain’ in index.php. Otherwise, all my segment emails were sent with links being overwritten by reverse proxy’s url instead of Mautic’s site_url.