前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Matomo的Nginx配置

Matomo的Nginx配置

作者头像
CiiLii西里网
发布2023-04-19 11:01:43
5720
发布2023-04-19 11:01:43
举报
文章被收录于专栏:ECS服务器

This is a small nginx configuration that should help you get your own Matomo instance running and start collecting your own analytics. 这是一个小的nginx配置,可以帮助您运行自己的Matomo实例并开始收集自己的分析。

I already know nginx

已经知道nginx了

In this case it should be enough to just take the sites-available/matomo.conf, check if everything is configured as you like it and enable the config. 在这种情况下,只需要获取sites-available/matomo.conf,检查是否一切都按照您喜欢的方式配置,并启用配置就足够了。

I want to get started

我想开始了

  • clone this repostitory or download it as a zip then move its content to /etc/nginx/ (or wherever you store your nginx-config) 克隆这个仓库或者下载一个zip文件,然后把它的内容移动到/etc/nginx/(或者你保存nginx-config的地方)
  • read through the 通读 sites-available/matomo.conf and modify the settings to fit your use case: 并修改设置以适合您的使用情形:
    • set server_name to the domain(s) of your Matomo instance 将 server_name设置为Matomo实例的域
    • set the path to your SSL certificate (I really recommend you to make sure your Matomo instance is only reachable via HTTPS. If you don't have an SSL certificate for your domain yet, check out Let's Encrypt.) 设置SSL证书的路径(我强烈建议您确保您的Matomo实例只能通过HTTPS访问。如果您的域名还没有SSL证书,请查看Let's Encrypt
    • do you want to support old browsers? Then you'll need to modify ssl.conf according to your need. (the Mozilla SSL Config Generator will help you) 你想支持旧的浏览器吗?那你就需要修改 ssl.conf根据您的需要。(the Mozilla SSL配置生成器 会帮助你)
    • replace /var/www/matomo/ with the path to your Matomo instance 将 /var/www/matomo/替换为Matomo实例的路径
  • configure PHP (this depends on your OS and PHP setup) 配置PHP(这取决于您的操作系统和PHP设置)
    • if you are using fastcgi (which is probably the case) set fastcgi_pass to the path of your PHP socket file 如果您正在使用fastcgi(很可能就是这种情况),请将fastcgi_pass设置为PHP套接字文件的路径
    • you can also specify a TCP port也可以指定TCP端口
  • go to the sites-enabled folder of your nginx config directory 转到 站点启用nginx配置目录的文件夹
  • enable the Matomo config by creating a symlink: sudo ln -s ../sites-available/matomo.conf 通过创建符号链接启用Matomo配置:sudoln -s../ sites-available/matomo.conf
  • test if there is a syntax error in your config: sudo nginx -t 测试配置中是否存在语法错误:sudonginx -t
  • restart nginx: sudo systemctl restart nginx 重启nginx:sudosystemctl restart nginx

If you need to check the legacy nginx Matomo configuration, you can find it here: https://github.com/matomo-org/matomo-nginx/tree/1.0.99 如果您需要检查遗留的nginx Matomo配置,您可以在这里找到它:https://github.com/matomo—org/matomo—nginx/tree/1.0.99

Tips

  • never use Matomo without HTTPS不要在没有HTTPS的情况下使用Matomo
  • make sure you have configured Nginx to only accept modern and secure cryptography 请确保您已将Nginx配置为仅接受现代和安全的加密
  • add server_tokens off; to your config to disable the server: nginx header on all requests and the nginx version on error pages 添加 server_tokens off;到您的配置中以禁用所有请求上的server:nginx头和错误页面上的nginx版本
  • if you have enabled gzip compression (which improves performance greatly), be aware of the BREACH vulnerability 如果您启用了gzip压缩(这可以大大提高性能),请注意BREACH漏洞
  • think about enabling the Strict-Transport-Security header, but keep in mind the implications 考虑启用 Strict-Transport-Security报头,但要记住其含义
  • keep HTTP/2 enabled as it brings performance benifits with many small files (e.g. icons) 保持HTTP/2启用,因为它可以为许多小文件(如图标)带来性能优势

You know how to improve this config? Open a pull request or GitHub issue! 你知道如何改进这个配置吗?打开pull request或GitHub issue!

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • I already know nginx
  • 已经知道nginx了
  • I want to get started
  • 我想开始了
  • Tips
相关产品与服务
SSL 证书
腾讯云 SSL 证书(SSL Certificates)为您提供 SSL 证书的申请、管理、部署等服务,为您提供一站式 HTTPS 解决方案。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档