From afc1c2ecaf4ea263c26645d4338a2ed77b262311 Mon Sep 17 00:00:00 2001 From: Daniel Jagszent Date: Wed, 7 Apr 2021 14:23:40 +0200 Subject: [PATCH] Ensure that we always have two capture groups in nginx redirect regex expressions We sometimes had one and mostly had two capture groups. Now we always have two capture groups and thus can always use $2 for the redirect target. Fixes #6144 --- server/conf/nginx_vhost.conf.master | 4 ++-- server/plugins-available/nginx_plugin.inc.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/conf/nginx_vhost.conf.master b/server/conf/nginx_vhost.conf.master index d5e457b9e3..50c0cf5183 100644 --- a/server/conf/nginx_vhost.conf.master +++ b/server/conf/nginx_vhost.conf.master @@ -60,13 +60,13 @@ server { if ($http_host "") { - rewrite ^(.*)$ $1 ; + rewrite ^(.*)$ $2 ; } - if ($http_host != "") { rewrite ^(.*)$ $1 ; } + if ($http_host != "") { rewrite ^(.*)$ $2 ; } location / { diff --git a/server/plugins-available/nginx_plugin.inc.php b/server/plugins-available/nginx_plugin.inc.php index 92d8bac7f9..2a1ba6c13a 100644 --- a/server/plugins-available/nginx_plugin.inc.php +++ b/server/plugins-available/nginx_plugin.inc.php @@ -1499,7 +1499,7 @@ class nginx_plugin { } } else { // external URL - $rewrite_exclude = '(?!\.well-known/acme-challenge)/'; + $rewrite_exclude = '(?!/(\.well-known/acme-challenge))/'; if($data['new']['redirect_type'] == 'proxy'){ $vhost_data['use_proxy'] = 'y'; $rewrite_subdir = $tmp_redirect_path_parts['path']; @@ -1551,7 +1551,7 @@ class nginx_plugin { } } else { // external URL - $rewrite_exclude = '(?!\.well-known/acme-challenge)/'; + $rewrite_exclude = '(?!/(\.well-known/acme-challenge))/'; if($data['new']['redirect_type'] == 'proxy'){ $vhost_data['use_proxy'] = 'y'; $rewrite_subdir = $tmp_redirect_path_parts['path']; @@ -1601,7 +1601,7 @@ class nginx_plugin { } } else { // external URL - $rewrite_exclude = '(?!\.well-known/acme-challenge)/'; + $rewrite_exclude = '(?!/(\.well-known/acme-challenge))/'; if($data['new']['redirect_type'] == 'proxy'){ $vhost_data['use_proxy'] = 'y'; $rewrite_subdir = $tmp_redirect_path_parts['path']; -- GitLab