PIWIK是一款开源的Web统计软件,作用和百度统计、Google Analytics相同,但是PIWIK可以完全自行搭建。

由于在PIWIK启用了CDN,导致获取的访客IP全是CDN节点,好在PIWIK官方早就考虑了这一点,解决办法为:找到config/config.ini.php在文件在[General]后面添加如下代码即可生效。

proxy_client_headers[] = HTTP_X_FORWARDED_FOR
proxy_host_headers[] = HTTP_X_FORWARDED_HOST

proxy_client_headers[] = HTTP_CF_CONNECTING_IP

proxy_client_headers[] = HTTP_CLIENT_IP
proxy_client_headers[] = HTTP_X_REAL_IP