Matomo behind loadbalancer and CloudFront reports the wrong public port

Matomo is used behind a load balancer (AWS) with dedicated port and CloudFront (AWS). The Matomo installation is running on docker (matomo:latest) and uses internally port 80. External port for load balancer is port 6000 - that’s the port CloudFront uses too to communicate with the load balancer. General public URL is standard 443 https://statistics.example.com. For some resources (logo uploaded) and within the tracker-info we have the wrong info like https://statistics.example.com:6000 - how can we override/set standard URL?

Fixed it with a simple, but for sure not beautiful solution, based on https://stackoverflow.com/a/17181672 - so we added in main /var/www/html a .htaccess file, added the following line:

php_value auto_prepend_file change_hostinfo.php

then we created a change_hostinfo.php with the following content:

<?php
$_SERVER['HTTP_HOST'] = 'statistics.mydomain.com';
$_SERVER['HTTP_X_FORWARDED_PORT'] = '80';
?>

And the problem was solved. Again, not nice, but does the trick.

1 Like