diff --git a/package.json b/package.json index df17017..2b15359 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "unplugin-https-reverse-proxy", "type": "module", - "version": "2.0.3-beta.1", + "version": "2.0.3-beta.2", "description": "", "license": "MIT", "homepage": "https://github.com/zcf0508/unplugin-https-reverse-proxy#readme", diff --git a/src/caddy/caddyfile.ts b/src/caddy/caddyfile.ts index 8415455..49d272b 100644 --- a/src/caddy/caddyfile.ts +++ b/src/caddy/caddyfile.ts @@ -7,6 +7,7 @@ export const ProxyType = type({ tls: 'string', source: 'string', base: 'string', + health_check: 'boolean', }) const CaddyContext = type({ @@ -48,7 +49,7 @@ export const caddyTemplate = `{ {% for p in proxies %} {{ p.target }}{{ p.port_suffix }} { {{ p.tls }} - reverse_proxy http://{{ p.source }} { + reverse_proxy http://{{ p.source }} {% if p.health_check %} { health_uri {{ p.base }} health_interval 2s health_timeout 5s @@ -56,11 +57,6 @@ export const caddyTemplate = `{ unhealthy_status 502 503 504 404 lb_try_duration 3s lb_try_interval 300ms - health_headers { - Accept text/html - Accept-Encoding gzip, deflate, br - User-Agent Caddy-Health-Check - } @error status 502 503 504 404 handle_response @error { @@ -70,6 +66,7 @@ export const caddyTemplate = `{ } } } + {% endif %} } {% endfor %} ` diff --git a/src/caddy/index.ts b/src/caddy/index.ts index 6f74086..2b2b31a 100644 --- a/src/caddy/index.ts +++ b/src/caddy/index.ts @@ -102,6 +102,7 @@ interface RunOptions { base: string showCaddyLog: boolean https: boolean + health_check?: boolean } const { cleanUp, configJsonRef, writeCaddyConfig } = useCaddyConfig() @@ -177,6 +178,7 @@ export class CaddyInstant { base = '/', showCaddyLog = false, https = false, + health_check = true, } = options || {} this._source = source @@ -198,6 +200,7 @@ export class CaddyInstant { tls: https ? 'tls internal' : '', source, base, + health_check, }, ] diff --git a/src/types.ts b/src/types.ts index 3f8d2a4..e2a9c06 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,4 +5,5 @@ export interface Options { showCaddyLog?: boolean /** default `false` */ https?: boolean + health_check?: boolean }