Jack Moore

Email: jack(at)jmoore53.com
Project Updates

Matomo Server

04 Dec 2023 » code, infrastructure, docker

Analytics provide valuable insights into website traffic and user behavior, which are crucial for optimizing online presence and performance. Implementing Matomo, an open-source web analytics platform, enables detailed tracking and analysis.

Setting up a Matomo server involves several steps, including configuring the server, setting up a reverse proxy, and securing the environment.

Server Configuration:

A server was built to host Matomo, and configurations were carefully documented. The .example folder was placed in the /opt directory to serve as a reference for configuration files.

Database Configuration:

Passwords and other sensitive information were managed using a db.env file. The following configuration was applied to the config.php.ini file to connect Matomo with the database:

[database]
host = "db"
username = "matomo"
password = "P@ssword123"
dbname = "matomo"
tables_prefix = "matomo_"
charset = "utf8mb4"

[General]
salt = "salty"
trusted_hosts[] = "analytics.jmoore53.com"
trusted_hosts[] = "hrvmatp1.cell.jmoore53.com:8080"
trusted_hosts[] = "jmoore53.com"
proxy_client_headers[] = HTTP_X_FORWARDED_FOR

This configuration specifies the database connection settings and lists trusted hosts to ensure secure connections to the Matomo server.

Nginx Reverse Proxy Setup:

Nginx was configured as a reverse proxy to handle incoming requests and direct them to the appropriate server. The setup included adding a certificate and configuring DNS for domain resolution. The Nginx configuration file used for the setup is as follows:

server {
    server_name analytics.jmoore53.com;

    location / {
        proxy_pass http://hrvmatp1.cell.jmoore53.com:8080;
        include proxy_params;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_headers_hash_max_size 512;
        proxy_headers_hash_bucket_size 128;
    }

    ...etc
}

This configuration allows Nginx to act as a gatekeeper, forwarding traffic to the Matomo server while maintaining security and performance.

The server setup was completed by adding DNS records and ensuring that all services are correctly configured and running. The Matomo server is now operational, providing comprehensive analytics for the specified domains.

© Jack Moore - This site was last built Fri 30 Aug 2024 12:31:24 PM EDT