summaryrefslogtreecommitdiff
path: root/caddytest
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2022-03-06 17:43:39 -0700
committerGitHub <noreply@github.com>2022-03-06 17:43:39 -0700
commitab0455922ae01bde1a7a5b3bf58eb993efc02db7 (patch)
tree6ecfccc2d29d601fab557092545fddb51ba1ebea /caddytest
parentc50094fc9d34099efd705700e6d2efa2fa065412 (diff)
reverseproxy: Dynamic upstreams (with SRV and A/AAAA support) (#4470)
* reverseproxy: Begin refactor to enable dynamic upstreams Streamed here: https://www.youtube.com/watch?v=hj7yzXb11jU * Implement SRV and A/AAA upstream sources Also get upstreams at every retry loop iteration instead of just once before the loop. See #4442. * Minor tweaks from review * Limit size of upstreams caches * Add doc notes deprecating LookupSRV * Provision dynamic upstreams Still WIP, preparing to preserve health checker functionality * Rejigger health checks Move active health check results into handler-specific Upstreams. Improve documentation regarding health checks and upstreams. * Deprecation notice * Add Caddyfile support, use `caddy.Duration` * Interface guards * Implement custom resolvers, add resolvers to http transport Caddyfile * SRV: fix Caddyfile `name` inline arg, remove proto condition * Use pointer receiver * Add debug logs Co-authored-by: Francis Lavoie <lavofr@gmail.com>
Diffstat (limited to 'caddytest')
-rw-r--r--caddytest/integration/caddyfile_adapt/reverse_proxy_dynamic_upstreams.txt116
-rw-r--r--caddytest/integration/caddyfile_adapt/reverse_proxy_options.txt7
2 files changed, 123 insertions, 0 deletions
diff --git a/caddytest/integration/caddyfile_adapt/reverse_proxy_dynamic_upstreams.txt b/caddytest/integration/caddyfile_adapt/reverse_proxy_dynamic_upstreams.txt
new file mode 100644
index 0000000..2f2cbcd
--- /dev/null
+++ b/caddytest/integration/caddyfile_adapt/reverse_proxy_dynamic_upstreams.txt
@@ -0,0 +1,116 @@
+:8884 {
+ reverse_proxy {
+ dynamic a foo 9000
+ }
+
+ reverse_proxy {
+ dynamic a {
+ name foo
+ port 9000
+ refresh 5m
+ resolvers 8.8.8.8 8.8.4.4
+ dial_timeout 2s
+ dial_fallback_delay 300ms
+ }
+ }
+}
+
+:8885 {
+ reverse_proxy {
+ dynamic srv _api._tcp.example.com
+ }
+
+ reverse_proxy {
+ dynamic srv {
+ service api
+ proto tcp
+ name example.com
+ refresh 5m
+ resolvers 8.8.8.8 8.8.4.4
+ dial_timeout 1s
+ dial_fallback_delay -1s
+ }
+ }
+}
+
+----------
+{
+ "apps": {
+ "http": {
+ "servers": {
+ "srv0": {
+ "listen": [
+ ":8884"
+ ],
+ "routes": [
+ {
+ "handle": [
+ {
+ "dynamic_upstreams": {
+ "name": "foo",
+ "port": "9000",
+ "source": "a"
+ },
+ "handler": "reverse_proxy"
+ },
+ {
+ "dynamic_upstreams": {
+ "dial_fallback_delay": 300000000,
+ "dial_timeout": 2000000000,
+ "name": "foo",
+ "port": "9000",
+ "refresh": 300000000000,
+ "resolver": {
+ "addresses": [
+ "8.8.8.8",
+ "8.8.4.4"
+ ]
+ },
+ "source": "a"
+ },
+ "handler": "reverse_proxy"
+ }
+ ]
+ }
+ ]
+ },
+ "srv1": {
+ "listen": [
+ ":8885"
+ ],
+ "routes": [
+ {
+ "handle": [
+ {
+ "dynamic_upstreams": {
+ "name": "_api._tcp.example.com",
+ "source": "srv"
+ },
+ "handler": "reverse_proxy"
+ },
+ {
+ "dynamic_upstreams": {
+ "dial_fallback_delay": -1000000000,
+ "dial_timeout": 1000000000,
+ "name": "example.com",
+ "proto": "tcp",
+ "refresh": 300000000000,
+ "resolver": {
+ "addresses": [
+ "8.8.8.8",
+ "8.8.4.4"
+ ]
+ },
+ "service": "api",
+ "source": "srv"
+ },
+ "handler": "reverse_proxy"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/caddytest/integration/caddyfile_adapt/reverse_proxy_options.txt b/caddytest/integration/caddyfile_adapt/reverse_proxy_options.txt
index 70e7af6..e41b900 100644
--- a/caddytest/integration/caddyfile_adapt/reverse_proxy_options.txt
+++ b/caddytest/integration/caddyfile_adapt/reverse_proxy_options.txt
@@ -17,6 +17,7 @@ https://example.com {
dial_fallback_delay 5s
response_header_timeout 8s
expect_continue_timeout 9s
+ resolvers 8.8.8.8 8.8.4.4
versions h2c 2
compression off
@@ -88,6 +89,12 @@ https://example.com {
"max_response_header_size": 30000000,
"protocol": "http",
"read_buffer_size": 10000000,
+ "resolver": {
+ "addresses": [
+ "8.8.8.8",
+ "8.8.4.4"
+ ]
+ },
"response_header_timeout": 8000000000,
"versions": [
"h2c",