Skip to content

Commit 469d663

Browse files
0x28dgdzien
authored andcommitted
Add proxy_redirect parameter for location blocks (#102)
* Add proxy_redirect parameter for http and location blocks (#1) * Use ternary() filter to handle proxy_redirect parameter
1 parent 589d668 commit 469d663

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ nginx_http_template:
374374
proxy_ignore_headers:
375375
- Vary
376376
- Cache-Control
377+
proxy_redirect: false
377378
websocket: false
378379
auth_basic: null
379380
auth_basic_file: null

templates/http/default.conf.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ server {
7575
auth_basic_user_file {{ item.value.reverse_proxy.locations[location].auth_basic_file }};
7676
{% endif %}
7777
proxy_pass {{ item.value.reverse_proxy.locations[location].proxy_pass }};
78-
78+
{% if item.value.reverse_proxy.locations[location].proxy_redirect is defined %}
79+
proxy_redirect {{ item.value.reverse_proxy.locations[location].proxy_redirect | ternary(item.value.reverse_proxy.locations[location].proxy_redirect, "off") }};
80+
{% endif %}
7981
{% if item.value.reverse_proxy.locations[location].proxy_cache is defined %}
8082
proxy_cache {{ item.value.reverse_proxy.locations[location].proxy_cache }};
8183
{% endif %}

tests/playbooks/nginx-http-template.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
proxy_ignore_headers:
6060
- Vary
6161
- Cache-Control
62+
proxy_redirect: false
6263
backend:
6364
location: /backend
6465
proxy_pass: http://backend_servers/
@@ -72,6 +73,7 @@
7273
- http_500
7374
- http_502
7475
- http_503
76+
proxy_redirect: default
7577
upstreams:
7678
frontend_upstream:
7779
name: frontend_servers

0 commit comments

Comments
 (0)