Skip to content

Commit 432062e

Browse files
authored
Merge pull request #1559 from jc21/variable-fix-custom-locations
Fixes custom location with capture groups
2 parents 0c8bbb4 + c203d1a commit 432062e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

backend/templates/_location.conf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
location {{ path }} {
2-
set $upstream {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }}{{ forward_path }}$request_uri;
2+
set $targetUri {{ forward_scheme }}://{{ forward_host }}:{{ forward_port }}{{ forward_path }};
3+
{% unless path contains "~" and path contains "(" and path contains ")" %}
4+
if ($request_uri != /){
5+
set $targetUri $targetUri$request_uri;
6+
}
7+
{% endunless %}
38
proxy_set_header Host $host;
49
proxy_set_header X-Forwarded-Scheme $scheme;
510
proxy_set_header X-Forwarded-Proto $scheme;
611
proxy_set_header X-Forwarded-For $remote_addr;
712
proxy_set_header X-Real-IP $remote_addr;
8-
proxy_pass $upstream;
13+
proxy_pass $targetUri;
914

1015
{% if access_list_id > 0 %}
1116
{% if access_list.items.length > 0 %}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
set $upstream $forward_scheme://$server:$port$request_uri;
1+
set $targetUri $forward_scheme://$server:$port$request_uri;
22
add_header X-Served-By $host;
33
proxy_set_header Host $host;
44
proxy_set_header X-Forwarded-Scheme $scheme;
55
proxy_set_header X-Forwarded-Proto $scheme;
66
proxy_set_header X-Forwarded-For $remote_addr;
77
proxy_set_header X-Real-IP $remote_addr;
8-
proxy_pass $upstream;
8+
proxy_pass $targetUri;
99

0 commit comments

Comments
 (0)