有关使用轻量级服务器Matomo 镜像的常见问题

  备案动态     |      2023-08-24
有关使用轻量级服务器Matomo 镜像的常见问题

上一篇文章《免费网站统计已是穷途末路,自建统计系统势在必行》发布后,我们收集了大家比较关心的几个问题,在这里一一解答。

重要提示

由于Lighthouse 应用程序安装在/usr/local/lighthouse/softwares/目录中,因此下文中所有不以/开头的路径均指在此目录中。

配置域名 和 https

当前通过不安全的HTTP 使用Matomo,这使得Matomo 容易受到安全漏洞的影响。它还可能违反隐私法,因为某些功能(包括选择退出cookie)将不可用。我们建议您将Matomo 设置为使用SSL (HTTPS) 以提高安全性。

安装Matomo后,进入后台,会有如上提示,按照以下方法配置https即可解决此问题:

修改Matomo配置文件matomo/config/config.ini.php,在【General】配置部分添加自己的域名trusted_hosts[]='ma.rehiy.com',复制并编辑Nginx配置文件nginx/conf/include/matomo.conf,替换listen 80 default_server;包含以下内容:listen 80;listen 443 ssl;server_name ma.rehiy.com;ssl_certificate certs/rehiy.com.cer;ssl_certificate_key certs/rehiy.com.key; copy reload Nginx 配置systemctl reload nginx copy

获得客户真实 ip 地址

如果为Matomo 配置了CDN,可能会出现无法获取客户端真实IP 地址的情况。您可以参考以下方法解决:

提示:以下腾讯云CDN地址列表可能会发生变化,您可以通过控制台获取最新列表。如果使用其他CDN,也可以按照格式添加条目。

创建Nginx配置文件nginx/conf/http.d/real-ip.conf,内容如下:real_ip_recursive on;real_ip_header X-Forwarded-For;# private ip listset_real_ip_from 10.0.0.0/8;set_real_ip_from 127.0.0.0/8 ;set_real_ip_from 169.2 54 .0.0/16;set_real_ip_from 172.16.0.0/12;set_real_ip_from 192.168.0.0/16;#腾讯云cdn set_real_ip_from 101.89.27.0/24;set_real_ip_from 101.89.32.0/2 4;set_real_ip_from 101.89.34.0/24; set_real_ip_from 101.91.24.0/24; set_real_ip_from 112.53.38.0/24;set_real_ip_from 116.128.128.0/24;set_real_ip_from 119.188.19.0/24;set_real_ip_from 120.221.167.0/24;set_real_ip_from 120.22 1.168.0/24 ;set_real_ip_from 121.51.191.0/24;set_real_ip_from 121.51.90.0/24; set_real_ip_from 121.51.93.0/24;set_real_ip_from 122.97.142.0/24;set_real_ip_from 122.97.143.0/24;set_real_ip_from 123.151.144.0/24;set_real_ip_from 140.249.67.0/24;设置_real_ip_from 182.254.58.0/24;set_real_ip_from 220.194.88.0/24; set_real_ip_from 223.166 .151.0/24;set_real_ip_from 27.155.114.0/24;set_real_ip_from 27.155.115.0/24;set_real_ip_from 36.152.58.0/24;set_real_ip_from 36.248.2.0/24;set_real _ip_from 58.217.244.0/24;set_real_ip_from 58.217.245.0/24;set_real_ip_from 58.251。 121.0/24;set_real_ip_from 59.36.117.0/24;set_real_ip_from 59.36.119.0/24;set_real_ip_from 59.36.120.0/24;set_real_ip_from 59.36.95.0/24;set_real_ip_from 61.151.164.0 /24; copy reload Nginx config systemctl reload nginx copy:010 -1010 编辑文件matomo/plugins/Login/templates/layout.twig,在Template.pageFooter后面添加以下代码

div style='text-align:center'a href='https://beian.miit.gov.cn'京ICP备00000000-0/a/div 最后复制保存,记得将文件编码改为utf-8,编码不正确的话,就会出现乱码。

注意:这样做会导致后台系统检查显示:文件完整性检查失败并报告一些错误。虽然可以通过修改系统的完整性检查文件来绕过该提示,但这里不给出方法。毕竟它可以提醒你哪些文件被修改了,方便升级时的兼容。

添加 ICP 备案号

使用Matomo/Piwik 定期导入日志,实现网站访问统计手动删除Matomo/Piwik 历史日志(MySQL 删除大量数据)腾云先锋(TDP,TencentCloudDeveloperPioneer)是腾讯云GTS 官方建立并运营的技术开发者小组。这里有最专业的开发者客户,有与产品人员的密切接触,有专属的问题需求反馈渠道,有一群志同道合的兄弟姐妹。快来加入我们的开发者社区吧。