Skip to content

Commit

Permalink
Fix matomo redirect when user log in (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
pastakhov authored Sep 21, 2024
1 parent 44655df commit 071f923
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 9 additions & 0 deletions _resources/matomo-bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

// Modify Matomo configuration settings to Ensure Matomo redirects correctly when behind a proxy server.
// It uses the X-Forwarded-Uri header (the proxy server should pass it)
// See MBSD-296 for details
$GLOBALS['MATOMO_MODIFY_CONFIG_SETTINGS'] = function ( $settings ) {
$settings['General']['proxy_uri_header'] = 1;
return $settings;
};
10 changes: 5 additions & 5 deletions compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ services:
- MATOMO_DATABASE_PASSWORD=$MW_DB_INSTALLDB_PASS
volumes:
- ./_data/matomo:/var/www/html
- ./_resources/matomo-bootstrap.php:/var/www/html/bootstrap.php
labels:
# Ofelia
- ofelia.enabled=true
Expand All @@ -132,14 +133,13 @@ services:
- traefik.enable=true
- traefik.docker.network=traefik-public
- traefik.constraint-label=traefik-public
- traefik.http.routers.${COMPOSE_PROJECT_NAME}-matomo.rule=Host(`${MW_SITE_FQDN?Variable not set}`) && PathPrefix(`/matomo/`)
- traefik.http.routers.${COMPOSE_PROJECT_NAME}-matomo.rule=Host(`${MW_SITE_FQDN?Variable MW_SITE_FQDN not set}`) && PathPrefix(`/${MATOMO_FOLDER:-matomo}/`)
- traefik.http.routers.${COMPOSE_PROJECT_NAME}-matomo.entrypoints=websecure
- traefik.http.routers.${COMPOSE_PROJECT_NAME}-matomo.tls.certresolver=le
- traefik.http.middlewares.${COMPOSE_PROJECT_NAME}-matomo-stripprefix.stripprefix.prefixes=/matomo
- traefik.http.middlewares.${COMPOSE_PROJECT_NAME}-matomo-stripprefix.stripprefix.prefixes=/${MATOMO_FOLDER:-matomo}
- traefik.http.middlewares.${COMPOSE_PROJECT_NAME}-matomo-stripprefix.stripprefix.forceSlash=true
- "traefik.http.middlewares.${COMPOSE_PROJECT_NAME}-matomo-redirect.redirectregex.regex=^https://([^\\/]+)/matomo/$$"
- "traefik.http.middlewares.${COMPOSE_PROJECT_NAME}-matomo-redirect.redirectregex.replacement=https://$${1}/matomo/index.php?module=CoreHome"
- traefik.http.routers.${COMPOSE_PROJECT_NAME}-matomo.middlewares=${COMPOSE_PROJECT_NAME}-matomo-redirect,${COMPOSE_PROJECT_NAME}-matomo-stripprefix
- traefik.http.middlewares.${COMPOSE_PROJECT_NAME}-matomo-headers.headers.customrequestheaders.X-Forwarded-Uri=/${MATOMO_FOLDER:-matomo}
- traefik.http.routers.${COMPOSE_PROJECT_NAME}-matomo.middlewares=${COMPOSE_PROJECT_NAME}-matomo-stripprefix,${COMPOSE_PROJECT_NAME}-matomo-headers


varnish:
Expand Down

0 comments on commit 071f923

Please sign in to comment.