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
The piwik.js file itself IS accessible from the browser.