sylvain durand

Access the logs of a shared OVH server

As it only weighs a few megabytes, does not generate any income and only has a few hundred visitors each day, I wanted to host this site on a free platform.

The advantage of static sites is that a lot of platforms actually offer free hosting: GitHub Pages, Netlify, Cloudflare, Render all offer a continuous integration that allows to generate and host a static site.

But I had another constraint: to be able to access the server logs, to be able to follow the number of visitors directly from the Matomo Log Analytics script, without imposing a tracker to the visitors.

I chose OVH, where I register my domain names, which “offers” with them a free shared hosting including a very generous storage space of… 10 megabytes. In my case, minimalism pays: it’s more than enough for me!

However, I found that the automated access to the logs was particularly badly documented, hence this short article!

Creating an account to access the logs

First of all, OVH requires the creation of a “user/password” pair to allow access to the logs. To do this, from the customer area, in Web Cloud, Hostings, select your domain name, then go to the Statistics and logs tab. In the User Administration section, create a username and password to access the logs.

Take the opportunity to note the log server access address, which is indicated in the “View logs” link, such as logs.clusterxxx.hosting.ovh.net.

Accessing the logs

To access the logs, a simple wget is enough with the right parameters. The following code retrieves the logs of the day before (to be then analyzed by Matomo for example):

LOG_SERVER="https://logs.clusterxxx.hosting.ovh.net/"
USER="youruser"
PASS="yourpassword"
SITE="domain.tdl"
MONTH=`date -d 'yesterday 13:00' '+%m-%Y'`
DATE=`date -d 'yesterday 13:00' '+%d-%m-%Y'`

wget --http-user=$USER --http-password=$PASS \
  $LOG_SERVER$SITE"/logs/logs-$MONTH/$SITE-$DATE.gz"