2

I am in the process of migrating a Drupal 7 website which uses Piwik (v. 3.0.3) to monitor visits.

There are some differences between the two VPS servers, but nothing of consequence (Old server: Ubuntu 12.04 / MySQL 5.5.54 / PHP 5.5.37 --> New server: Ubuntu 16.04 / MySQL 5.7.17 / PHP 5.6.30 or 7.1). Everything works correctly on the new server, apart from Piwik not logging visits. Also, the piwik directory is owned by www-data and Apache's mod_secure module is not loaded.

Following an error of Drupal's Piwik module:

The validation of "http://example.com/piwik/piwik.php" failed with error "Not Found" (HTTP code 404). The validation of "https://example.com/piwik/piwik.php" failed with error "Error opening socket ssl://mysite.org:443" (HTTP code 0).

I tracked the problem down to the fact that the new server is accessible by 1:1 NAT conversion, with a 172.x.y.z local IP. Apparently, the VPS host has changed policies regarding IPv4 addresses without informing customers (as described here).

After I added 172.x.y.z to the Trusted Piwik Hostnames in Piwik's interface, the above error disappeared, but I can still get no logging of visits.

I am really stumped and would appreciate any help I can get. I am otherwise satisfied with my VPS host and would like to avoid the hassle of finding another one to migrate my site(s).

EDIT 1: Using the Firefox's Web Developer Network tab as proposed by TdotThomas, I find that piwik.js has a red square and gives headers:

Request URL: http://example.com/piwik/piwik.js

Request method: GET

Remote address: (the external IP)

Status code: 404 Not found

Version:HTTP/1.1

The piwik.js file itself IS accessible from the browser.

EDIT 2: On the piwik interface I change the Trusted Hostnames to 172.x.y.z/var/www/piwik and to example.com/piwik or http://example.com or http://example.com/piwik. Still nothing. In Drupal's Piwik module (which provides each page with the appropriate Javascript code) I have entered all these variations.

  • Please make sure you use a FQDN while it should work with an IP address it hasn't in my experience. – T. Thomas Apr 26 '17 at 14:06
  • Thanks for the suggestion. Actually, in the Trusted Piwik Hostnames, I have added: (i) the public IP, (ii) the domain name ("example.com", without the "www", as I have decided to use the non-www domain name), AND (iii) the internal IP (172.x.y.z). Still, no luck. – user247471 Apr 26 '17 at 21:14
1

Make sure you use a FQDN while it should work with an IP address it has never worked in my experience.

Also make sure that you've added it to the website code correctly. I used firefox's developer network tab to see if it is fetching and loading correctly. You will see a green or red dot depending on if it loaded correctly or not.

Double check to make sure you have the paths set correctly in both piwik settings and the website tracker code.

Note: 172.x.y.z/path/to/piwik is not the same as example.com/path/to/piwik

Depending on your setup (sever OS and HTTP service) it might be something like 172.x.y.z/usr/home/www/path/to/piwik or something similar.

Last but now least check the permissions on the piwik folder.

  • @user247471 is the path to piwik.js correct? What error code do you see? – T. Thomas Apr 26 '17 at 21:57
  • I give additional information in my edits to the question – user247471 Apr 26 '17 at 22:23
  • @user247471 how about the permissions on the piwik folder? – T. Thomas Apr 26 '17 at 22:30
  • The piwik folder is owned by www-data:www-data with permissions 755. The files and folders inside it, in principle, have their original permissions (from the downloaded zip file). I don't think I changed anything. Actually, the piwik directory permissions are more permissive than in the working server (there, they are 750). – user247471 Apr 27 '17 at 6:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.