diff --git a/nginx.conf.template b/nginx.conf.template index 23b9229ad2b404871425de07cf91f1f4ad8a6428..5c47c2a6d39683e58d1dbb9fd40e7aa77d5e2183 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; + #} }