Skip to content

Commit 1ae67fc

Browse files
committed
feat: support disable health check
1 parent 63cfe15 commit 1ae67fc

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

src/caddy/caddyfile.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export const ProxyType = type({
77
tls: 'string',
88
source: 'string',
99
base: 'string',
10+
health_check: 'boolean',
1011
})
1112

1213
const CaddyContext = type({
@@ -48,19 +49,14 @@ export const caddyTemplate = `{
4849
{% for p in proxies %}
4950
{{ p.target }}{{ p.port_suffix }} {
5051
{{ p.tls }}
51-
reverse_proxy http://{{ p.source }} {
52+
reverse_proxy http://{{ p.source }} {% if p.health_check %} {
5253
health_uri {{ p.base }}
5354
health_interval 2s
5455
health_timeout 5s
5556
fail_duration 2s
5657
unhealthy_status 502 503 504 404
5758
lb_try_duration 3s
5859
lb_try_interval 300ms
59-
health_headers {
60-
Accept text/html
61-
Accept-Encoding gzip, deflate, br
62-
User-Agent Caddy-Health-Check
63-
}
6460
6561
@error status 502 503 504 404
6662
handle_response @error {
@@ -70,6 +66,7 @@ export const caddyTemplate = `{
7066
}
7167
}
7268
}
69+
{% endif %}
7370
}
7471
{% endfor %}
7572
`

src/caddy/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ interface RunOptions {
102102
base: string
103103
showCaddyLog: boolean
104104
https: boolean
105+
health_check?: boolean
105106
}
106107

107108
const { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig()
@@ -177,6 +178,7 @@ export class CaddyInstant {
177178
base = '/',
178179
showCaddyLog = false,
179180
https = false,
181+
health_check = true,
180182
} = options || {}
181183

182184
this._source = source
@@ -198,6 +200,7 @@ export class CaddyInstant {
198200
tls: https ? 'tls internal' : '',
199201
source,
200202
base,
203+
health_check,
201204
},
202205
]
203206

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export interface Options {
55
showCaddyLog?: boolean
66
/** default `false` */
77
https?: boolean
8+
health_check?: boolean
89
}

0 commit comments

Comments
 (0)