democratech / 2022

4 stars 2 forks source link

Fix "non secure connection on the server" warning on Matomo #33

Open JMLX42 opened 3 years ago

JMLX42 commented 3 years ago

image

This warning is because the SSL is provided by the Nginx proxy + Let'sEncrypt + Cloudflare. So Matomo sees an https URL but actually runs HTTP on the 80 port.

The solution is to add the line assume_secure_protocol=1 below the [General] section in the Matomo configuration.

JMLX42 commented 3 years ago

Sadly, there is no env var to set this directly from the docker-compose.yml file: https://github.com/bitnami/bitnami-docker-matomo/issues/71

JMLX42 commented 3 years ago

Here is how to fix it:

- name: wait for config.ini.php to be written
  wait_for:
    path: /data/matomo/data/config/config.ini.php
    search_regex: '^\[General\]$'

- name: set "assume_secure_protocol = 1"
  lineinfile:
    path: /data/matomo/data/config/config.ini.php
    line: "assume_secure_protocol = 1"
    insertafter: '^\[General\]$'
    state: present

:point_up_2: this must be added at the end of the role's tasks.