From 6483e99f498e0e159f750d3fb93d6ba1dc9c9797 Mon Sep 17 00:00:00 2001
From: Alessandro Cerioni <acerioni@grandlyon.com>
Date: Mon, 21 Jan 2019 18:42:39 +0100
Subject: [PATCH] Update nginx.conf.template, in order to make Matomo be loaded
 for both the EN and FR versions.

N.B.: Before this update, Matomo was only loaded for the EN version.
---
 nginx.conf.template | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/nginx.conf.template b/nginx.conf.template
index 23b9229a..5c47c2a6 100644
--- a/nginx.conf.template
+++ b/nginx.conf.template
@@ -21,10 +21,8 @@ server {
         })();
         </script>";
 
-    sub_filter '</head>' '$matomo_script</head>'; 
-
     # rule redirecting to fr or en regarding the browser preferences
-    location = / {
+    location / {
         rewrite_by_lua '
         for lang in (ngx.var.http_accept_language .. ","):gmatch("([^,]*),") do
             if string.sub(lang, 0, 2) == "en" then
@@ -41,16 +39,18 @@ server {
     # This is needed to allow reloading in the app when not on the base url as our app is an SPA
     location /en {
         try_files $uri$args /en/index.html;
+        sub_filter '</head>' '$matomo_script</head>'; 
     }
 
     location /fr {
         try_files $uri$args /fr/index.html;
+        sub_filter '</head>' '$matomo_script</head>'; 
         sub_filter '<html lang="en">' '<html lang="fr">'; 
     }
 
     # Allow to access the app without the /fr or /en and will by default redirect to /en/{path}
-    location / {
-        try_files $uri$args /en/index.html;
-    }
+    #location / {
+    #    try_files $uri$args /en/index.html;
+    #}
 
 }
-- 
GitLab