Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add args to nginx redirect map. #129 #130

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions images/nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 4 additions & 0 deletions images/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ http {

uninitialized_variable_warn off;

map $host$uri$args $redirectdomainargs {
include /etc/nginx/redirects-map-args.conf;
}

map $host$uri $redirectdomain {
include /etc/nginx/redirects-map.conf;
}
Expand Down
18 changes: 18 additions & 0 deletions images/nginx/redirects-map-args.conf
Original file line number Diff line number Diff line change
@@ -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;