@marcel91200 / caddy Mirror · read-only / commits / 07c86363
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 12, 10:45 UTC

reverseproxy: Caddyfile support for health_method (#6454)

* Add Caddyfile support of setting active health check request method * Add integration test for active health check request method

Jesper Brix Rosenkilde committed Jul 12, 2024 at 23:01 UTC 07c863637dff831c99d91cce129899ac8aa7b25c
2 files changed +53
caddytest/integration/caddyfile_adapt/reverse_proxy_health_method.caddyfiletest new
+40
@@ -0,0 +1,40 @@
1 +:8884
2 +
3 +reverse_proxy 127.0.0.1:65535 {
4 + health_uri /health
5 + health_method HEAD
6 +}
7 +----------
8 +{
9 + "apps": {
10 + "http": {
11 + "servers": {
12 + "srv0": {
13 + "listen": [
14 + ":8884"
15 + ],
16 + "routes": [
17 + {
18 + "handle": [
19 + {
20 + "handler": "reverse_proxy",
21 + "health_checks": {
22 + "active": {
23 + "method": "HEAD",
24 + "uri": "/health"
25 + }
26 + },
27 + "upstreams": [
28 + {
29 + "dial": "127.0.0.1:65535"
30 + }
31 + ]
32 + }
33 + ]
34 + }
35 + ]
36 + }
37 + }
38 + }
39 + }
40 +}
modules/caddyhttp/reverseproxy/caddyfile.go
+13
@@ -79,6 +79,7 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error)
79 // health_headers {
80 // <field> [<values...>]
81 // }
82 +// health_method <value>
83 //
84 // # passive health checking
85 // fail_duration <duration>
@@ -387,6 +388,18 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
388 }
389 h.HealthChecks.Active.Headers = healthHeaders
390
391 + case "health_method":
392 + if !d.NextArg() {
393 + return d.ArgErr()
394 + }
395 + if h.HealthChecks == nil {
396 + h.HealthChecks = new(HealthChecks)
397 + }
398 + if h.HealthChecks.Active == nil {
399 + h.HealthChecks.Active = new(ActiveHealthChecks)
400 + }
401 + h.HealthChecks.Active.Method = d.Val()
402 +
403 case "health_interval":
404 if !d.NextArg() {
405 return d.ArgErr()