Skip to content

Commit 375db94

Browse files
authored
Merge pull request #21 from simplificator/revert-18-master
Revert "Add option for insecure tls backend"
2 parents 7a0ae28 + 1f5fa1e commit 375db94

File tree

3 files changed

+16
-30
lines changed

3 files changed

+16
-30
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ N/A
1313
If you only want to install Caddy, you don't need to set any variables. If you want to configure Caddy as a reverse proxy as well, you can provide an array of objects named `caddy_sites` with the following values:
1414

1515
* `additional_forwarding_ports`: Allows to define a list with additional ports where Caddy should listen for this domain and forward to HTTPS.
16-
* `allowlist`: An array if IP addresses in CIDR-notation which are allowed to access this route (Optional). All other visitors receive a 404 error.
16+
* `allowlist`: An array if IP addresses in CIDR-notation which are allowed to access this site (Optional). All other visitors receive a 404 error.
1717
* `certificate_file`: You can set this variable if you want to provide the certificate by yourself (Optional). The certificate needs permissions `0640`, with root as Owner and Caddy as Group.
1818
* `certificate_key`: You can set this variable if you want to provide the certificate by yourself (Optional).
1919
* `domain`: The domain caddy should listen to.
@@ -67,15 +67,14 @@ With reverse proxy configuration and redirects:
6767
vars:
6868
caddy_sites:
6969
- domain: example.com
70-
tls_insecure: true
7170
routes:
7271
- path: ''
7372
reverse_proxy_destination: 192.168.50.2
74-
allowlist:
75-
- 8.8.8.8/32
7673
redirects:
7774
- source: ''
7875
target: '/'
76+
allowlist:
77+
- 8.8.8.8/32
7978
additional_forwarding_ports:
8079
- '8080'
8180
- '1337'

molecule/reverse-proxy/converge.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@
99
vars:
1010
caddy_sites:
1111
- domain: example.com
12-
tls_insecure: false
1312
routes:
1413
- path: ''
1514
reverse_proxy_destination: 192.168.50.2
16-
allowlist:
17-
- 8.8.8.8/32
1815
redirects:
1916
- source: ''
2017
target: /
2118
- source: '/about-us'
2219
target: '/about'
2320
code: 401
21+
allowlist:
22+
- 8.8.8.8/32
2423
additional_forwarding_ports:
2524
- '8080'
2625
- '1337'
@@ -34,10 +33,8 @@
3433
- path: '/public/*'
3534
ignore_allowlist: true
3635
reverse_proxy_destination: 192.168.50.3
37-
allowlist:
38-
- 8.8.8.8/32
3936
- path: '/protected/*'
4037
strip_prefix: true
4138
reverse_proxy_destination: 192.168.50.4
42-
allowlist:
43-
- 8.8.8.8/32
39+
allowlist:
40+
- 8.8.8.8/32

templates/Caddyfile.j2

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55

66
{% for site in caddy_sites %}
77
{{ site.domain }} {
8-
{% for route in site.routes %}
9-
{%- if route.allowlist is defined%}
10-
@allowlist{{loop.index}} {
11-
remote_ip {% for ip in route.allowlist %} {{ ip }}{% endfor %}
8+
{%- if site.allowlist is defined %}
9+
@allowlist {
10+
remote_ip {% for ip in site.allowlist %} {{ ip }}{% endfor %}
1211
}
1312

14-
@not_allowlist{{loop.index}} {
15-
not remote_ip {% for ip in route.allowlist %} {{ ip }}{% endfor %}
13+
@not_allowlist {
14+
not remote_ip {% for ip in site.allowlist %} {{ ip }}{% endfor %}
1615
}
1716
{% endif %}
18-
{% endfor %}
1917

2018
{%- if site.additional_template_path is defined %}
2119
{% include site.additional_template_path %}
@@ -33,19 +31,11 @@
3331
{%- else %}
3432
handle {{ route.path }} {
3533
{%- endif %}
36-
{%- if route.allowlist is defined and not (route.ignore_allowlist| default(false)) %}
37-
reverse_proxy @allowlist{{loop.index}} {{ route.reverse_proxy_destination }}{%- if site.tls_insecure%} {
38-
transport http {
39-
tls_insecure_skip_verify
40-
}
41-
}{%- endif %}
42-
respond @not_allowlist{{loop.index}} 404
34+
{%- if site.allowlist is defined and not (route.ignore_allowlist| default(false)) %}
35+
reverse_proxy @allowlist {{ route.reverse_proxy_destination }}
36+
respond @not_allowlist 404
4337
{%- else %}
44-
reverse_proxy {{ route.reverse_proxy_destination }}{%- if site.tls_insecure%} {
45-
transport http {
46-
tls_insecure_skip_verify
47-
}
48-
}{%- endif %}
38+
reverse_proxy {{ route.reverse_proxy_destination }}
4939
{%- endif %}
5040
}
5141
{%- endfor %}

0 commit comments

Comments
 (0)