-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
c50094f
commit ab04559
Showing
10 changed files
with
1,056 additions
and
281 deletions.
There are no files selected for viewing
116 changes: 116 additions & 0 deletions
116
caddytest/integration/caddyfile_adapt/reverse_proxy_dynamic_upstreams.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.