Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Piwik JS Tracking Code should use DNS name instead of IP #4486

Closed
anonymous-matomo-user opened this issue Jan 7, 2014 · 1 comment
Closed
Labels
Bug For errors / faults / flaws / inconsistencies etc. worksforme The issue cannot be reproduced and things work as intended.
Milestone

Comments

@anonymous-matomo-user
Copy link

Hi,

if you request the JS tracking Code via the API and the 'piwikUrl' Parameter isn't set, Piwik tries to recognize the correct URL. This is done in plugins/SitesManager/API.php function getJavascriptTag:

if (empty($piwikUrl)) {
    $piwikUrl = Url::getCurrentUrlWithoutFileName();
}

In times where we're trying to slowly migrate to IPv6 this is really bad! Piwik should use the DNS name, not the IP.

Request:

http://example.org/piwik/?module=API&method=SitesManager.getJavascriptTag&idSite=1&period=&date=&filter_limit=&token_auth=abcdefghij12354687&expanded=&format=PHP

Response:

s:880:"<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://2a02:8070:8360:xxxx:xxxx:85b0:xxxx:xxxx/piwik/";
    _paq.push(['setTrackerUrl', u+'piwik.php']);
    _paq.push(['setSiteId', 1]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
    g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
  })();

</script>
<noscript><p><img src="http://2a02:8070:8360:xxxx:xxxx:85b0:xxxx:xxxx/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
";

It would be great if someone with real understanding of Piwik and PHP could fix this.

Thanks in advance!

@robocoder
Copy link
Contributor

Check the trusted_hosts setting in your config.ini.php. The fallback to the server address happens if the value of the Host: header isn't in the trusted_hosts list.

@anonymous-matomo-user anonymous-matomo-user added this to the 2.0.3 - Piwik 2.0.3 milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. worksforme The issue cannot be reproduced and things work as intended.
Projects
None yet
Development

No branches or pull requests

3 participants