From 5bbf11dbe9d8378130f7e0e559a8a39c56f6dc99 Mon Sep 17 00:00:00 2001 From: "zxBAI Villanueva,Lucas (IT M+S) EXTERNAL" Date: Mon, 22 Mar 2021 18:32:17 -0300 Subject: [PATCH 1/5] Add args to nginx redirect map. #129 --- images/nginx/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/nginx/nginx.conf b/images/nginx/nginx.conf index 9ee0630a4..450ce20ee 100755 --- a/images/nginx/nginx.conf +++ b/images/nginx/nginx.conf @@ -33,7 +33,7 @@ http { uninitialized_variable_warn off; - map $host$uri $redirectdomain { + map $host$uri$args $redirectdomain { include /etc/nginx/redirects-map.conf; } From 440c430cec088dffdc5f910f5375729683367f03 Mon Sep 17 00:00:00 2001 From: "zxBAI Villanueva,Lucas (IT M+S) EXTERNAL" Date: Thu, 25 Mar 2021 18:27:40 -0300 Subject: [PATCH 2/5] separate args redirect map --- images/nginx/nginx.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/images/nginx/nginx.conf b/images/nginx/nginx.conf index 450ce20ee..4e2d21e1b 100755 --- a/images/nginx/nginx.conf +++ b/images/nginx/nginx.conf @@ -33,9 +33,12 @@ http { uninitialized_variable_warn off; - map $host$uri$args $redirectdomain { + map $host$uri $redirectdomain { include /etc/nginx/redirects-map.conf; } + map $host$uri$args $redirectdomain { + include /etc/nginx/redirects-map-args.conf; + } gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; From a60b5d3b5b5de0a559e4d07ad979353571b670c7 Mon Sep 17 00:00:00 2001 From: "zxBAI Villanueva,Lucas (IT M+S) EXTERNAL" Date: Thu, 25 Mar 2021 19:22:30 -0300 Subject: [PATCH 3/5] fix duplicated variable --- images/nginx/nginx.conf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/images/nginx/nginx.conf b/images/nginx/nginx.conf index 4e2d21e1b..71ac93955 100755 --- a/images/nginx/nginx.conf +++ b/images/nginx/nginx.conf @@ -36,7 +36,8 @@ http { map $host$uri $redirectdomain { include /etc/nginx/redirects-map.conf; } - map $host$uri$args $redirectdomain { + + map $host$uri$args $redirectdomainargs { include /etc/nginx/redirects-map-args.conf; } From 1e553bef274718acd470c9918e622f142e630613 Mon Sep 17 00:00:00 2001 From: "zxBAI Villanueva,Lucas (IT M+S) EXTERNAL" Date: Thu, 25 Mar 2021 20:24:54 -0300 Subject: [PATCH 4/5] adding examples, Dockerfile COPY and switching hierarchy --- images/nginx/Dockerfile | 1 + images/nginx/nginx.conf | 8 ++++---- images/nginx/redirects-map-args.conf | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 images/nginx/redirects-map-args.conf diff --git a/images/nginx/Dockerfile b/images/nginx/Dockerfile index 13293de7b..d16f58855 100644 --- a/images/nginx/Dockerfile +++ b/images/nginx/Dockerfile @@ -36,6 +36,7 @@ COPY fastcgi.conf /etc/nginx/fastcgi_params COPY helpers/ /etc/nginx/helpers/ COPY static-files.conf /etc/nginx/conf.d/app.conf COPY redirects-map.conf /etc/nginx/redirects-map.conf +COPY redirects-map-args.conf /etc/nginx/redirects-map-args.conf COPY healthcheck/healthz.locations healthcheck/healthz.locations.php.disable /etc/nginx/conf.d/ RUN mkdir -p /app \ diff --git a/images/nginx/nginx.conf b/images/nginx/nginx.conf index 71ac93955..8b1bc74c5 100755 --- a/images/nginx/nginx.conf +++ b/images/nginx/nginx.conf @@ -33,14 +33,14 @@ http { uninitialized_variable_warn off; - map $host$uri $redirectdomain { - include /etc/nginx/redirects-map.conf; - } - map $host$uri$args $redirectdomainargs { include /etc/nginx/redirects-map-args.conf; } + map $host$uri $redirectdomain { + include /etc/nginx/redirects-map.conf; + } + gzip on; gzip_disable "MSIE [1-6]\.(?!.*SV1)"; diff --git a/images/nginx/redirects-map-args.conf b/images/nginx/redirects-map-args.conf new file mode 100644 index 000000000..3b7fb87cb --- /dev/null +++ b/images/nginx/redirects-map-args.conf @@ -0,0 +1,18 @@ +## Nginx redirect map args +## This file is expected to have two entries per line: +## 1. source, which will be matched against '$host$uri$args' from nginx (so the hostname, uri and arguments) +## 2. destination of the redirect +## The file is read from top to bottom, so more specific sources need to be above more general matches +## A couple of examples: + +## Simple redirect matching a specific argument and value +# ~^example\.com\/?somekey=somevalue$ https://example.net; + +## Simple redirect matching a specific argument and value, preserving the arguments +# ~^example\.com\/?somekey=somevalue$ https://example.net$args; + +## Simple redirect matching a request that starts with a specific argument and value, preserving the arguments +# ~^example\.com\/?somekey=somevalue https://example.net$args; + +## Simple redirect matching a request that starts with a specific argument and value, preserving the URI and arguments +# ~^example\.com\/some/other/test?somekey=somevalue https://example.net$request_uri; From 16ad8bc1aa4184e2aed7d774bfcb047d8a076ec0 Mon Sep 17 00:00:00 2001 From: "zxBAI Villanueva,Lucas (IT M+S) EXTERNAL" Date: Thu, 25 Mar 2021 20:56:29 -0300 Subject: [PATCH 5/5] add new variable to helper --- images/nginx/helpers/010_redirects.conf | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/images/nginx/helpers/010_redirects.conf b/images/nginx/helpers/010_redirects.conf index 0431d1bba..523e044f9 100644 --- a/images/nginx/helpers/010_redirects.conf +++ b/images/nginx/helpers/010_redirects.conf @@ -1,4 +1,7 @@ # $redirectdomain is set via the redirects-map.conf within nginx.conf if ($redirectdomain) { return 301 $redirectdomain; -} \ No newline at end of file +} +if ($redirectdomainargs) { + return 301 $redirectdomainargs; +}