unplugin-https-reverse-proxy 2.0.3-beta.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-6ESO3Y2K.js → chunk-5MC5SB7O.js} +31 -22
- package/dist/esbuild.cjs +31 -22
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +31 -22
- package/dist/index.js +1 -1
- package/dist/nuxt.cjs +31 -22
- package/dist/nuxt.js +1 -1
- package/dist/rollup.cjs +31 -22
- package/dist/rollup.js +1 -1
- package/dist/rspack.cjs +31 -22
- package/dist/rspack.js +1 -1
- package/dist/types.d.cts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/vite.cjs +31 -22
- package/dist/vite.js +1 -1
- package/dist/webpack.cjs +31 -22
- package/dist/webpack.js +1 -1
- package/package.json +2 -1
- package/src/caddy/caddyfile.ts +5 -8
- package/src/caddy/config.ts +1 -1
- package/src/caddy/index.ts +17 -3
- package/src/types.ts +1 -0
|
@@ -13352,10 +13352,11 @@ var Liquid = class _Liquid {
|
|
|
13352
13352
|
// src/caddy/caddyfile.ts
|
|
13353
13353
|
var ProxyType = type({
|
|
13354
13354
|
target: "string",
|
|
13355
|
-
|
|
13355
|
+
portSuffix: "string",
|
|
13356
13356
|
tls: "string",
|
|
13357
13357
|
source: "string",
|
|
13358
|
-
base: "string"
|
|
13358
|
+
base: "string",
|
|
13359
|
+
healthCheck: "boolean"
|
|
13359
13360
|
});
|
|
13360
13361
|
var CaddyContext = type({
|
|
13361
13362
|
caddy_root: "string",
|
|
@@ -13391,9 +13392,9 @@ var caddyTemplate = `{
|
|
|
13391
13392
|
}
|
|
13392
13393
|
|
|
13393
13394
|
{% for p in proxies %}
|
|
13394
|
-
{{ p.target }}{{ p.
|
|
13395
|
+
{{ p.target }}{{ p.portSuffix }} {
|
|
13395
13396
|
{{ p.tls }}
|
|
13396
|
-
reverse_proxy http://{{ p.source }} {
|
|
13397
|
+
reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
|
|
13397
13398
|
health_uri {{ p.base }}
|
|
13398
13399
|
health_interval 2s
|
|
13399
13400
|
health_timeout 5s
|
|
@@ -13401,11 +13402,6 @@ var caddyTemplate = `{
|
|
|
13401
13402
|
unhealthy_status 502 503 504 404
|
|
13402
13403
|
lb_try_duration 3s
|
|
13403
13404
|
lb_try_interval 300ms
|
|
13404
|
-
health_headers {
|
|
13405
|
-
Accept text/html
|
|
13406
|
-
Accept-Encoding gzip, deflate, br
|
|
13407
|
-
User-Agent Caddy-Health-Check
|
|
13408
|
-
}
|
|
13409
13405
|
|
|
13410
13406
|
@error status 502 503 504 404
|
|
13411
13407
|
handle_response @error {
|
|
@@ -13415,6 +13411,7 @@ var caddyTemplate = `{
|
|
|
13415
13411
|
}
|
|
13416
13412
|
}
|
|
13417
13413
|
}
|
|
13414
|
+
{% endif %}
|
|
13418
13415
|
}
|
|
13419
13416
|
{% endfor %}
|
|
13420
13417
|
`;
|
|
@@ -13559,7 +13556,7 @@ var supportList = [
|
|
|
13559
13556
|
// src/caddy/config.ts
|
|
13560
13557
|
function useCaddyConfig() {
|
|
13561
13558
|
const configContentRef = signal("{}");
|
|
13562
|
-
const
|
|
13559
|
+
const configJsonRef = computed(() => {
|
|
13563
13560
|
try {
|
|
13564
13561
|
return JSON.parse(configContentRef());
|
|
13565
13562
|
} catch {
|
|
@@ -13582,26 +13579,26 @@ function useCaddyConfig() {
|
|
|
13582
13579
|
const watchCaddyConfig = watch(caddyConfigPath, () => {
|
|
13583
13580
|
setConfigContent();
|
|
13584
13581
|
});
|
|
13585
|
-
function
|
|
13586
|
-
const proxies =
|
|
13582
|
+
function writeCaddyConfig(_proxies) {
|
|
13583
|
+
const proxies = configJsonRef() || {};
|
|
13587
13584
|
_proxies.forEach((p) => {
|
|
13588
|
-
const index = `${p.target}${p.
|
|
13585
|
+
const index = `${p.target}${p.portSuffix}`;
|
|
13589
13586
|
proxies[index] = p;
|
|
13590
13587
|
});
|
|
13591
13588
|
const content = JSON.stringify(proxies, null, 2);
|
|
13592
13589
|
configContentRef(content);
|
|
13593
13590
|
return writeFileSync(caddyConfigPath, content);
|
|
13594
13591
|
}
|
|
13595
|
-
async function
|
|
13592
|
+
async function cleanUp() {
|
|
13596
13593
|
await unlink2(caddyConfigPath).catch(() => {
|
|
13597
13594
|
});
|
|
13598
13595
|
configContentRef("{}");
|
|
13599
13596
|
watchCaddyConfig.close();
|
|
13600
13597
|
}
|
|
13601
13598
|
return {
|
|
13602
|
-
configJsonRef
|
|
13603
|
-
writeCaddyConfig
|
|
13604
|
-
cleanUp
|
|
13599
|
+
configJsonRef,
|
|
13600
|
+
writeCaddyConfig,
|
|
13601
|
+
cleanUp
|
|
13605
13602
|
};
|
|
13606
13603
|
}
|
|
13607
13604
|
|
|
@@ -13735,7 +13732,13 @@ function testCaddy() {
|
|
|
13735
13732
|
});
|
|
13736
13733
|
});
|
|
13737
13734
|
}
|
|
13738
|
-
var
|
|
13735
|
+
var caddyConfig;
|
|
13736
|
+
function getCaddyConfig() {
|
|
13737
|
+
if (!caddyConfig) {
|
|
13738
|
+
caddyConfig = useCaddyConfig();
|
|
13739
|
+
}
|
|
13740
|
+
return caddyConfig;
|
|
13741
|
+
}
|
|
13739
13742
|
var CaddyInstant = class {
|
|
13740
13743
|
constructor() {
|
|
13741
13744
|
this.inited = false;
|
|
@@ -13787,7 +13790,8 @@ var CaddyInstant = class {
|
|
|
13787
13790
|
restore = true,
|
|
13788
13791
|
base = "/",
|
|
13789
13792
|
showCaddyLog = false,
|
|
13790
|
-
https = false
|
|
13793
|
+
https = false,
|
|
13794
|
+
healthCheck = true
|
|
13791
13795
|
} = options || {};
|
|
13792
13796
|
this._source = source;
|
|
13793
13797
|
this._target = target;
|
|
@@ -13800,15 +13804,18 @@ var CaddyInstant = class {
|
|
|
13800
13804
|
const proxies = [
|
|
13801
13805
|
{
|
|
13802
13806
|
target: targetHost,
|
|
13803
|
-
|
|
13807
|
+
portSuffix: https ? "" : ":80",
|
|
13804
13808
|
tls: https ? "tls internal" : "",
|
|
13805
13809
|
source,
|
|
13806
|
-
base
|
|
13810
|
+
base,
|
|
13811
|
+
healthCheck
|
|
13807
13812
|
}
|
|
13808
13813
|
];
|
|
13814
|
+
const { writeCaddyConfig } = getCaddyConfig();
|
|
13809
13815
|
writeCaddyConfig(proxies);
|
|
13810
13816
|
this._stopEffects.push(
|
|
13811
13817
|
effect(async () => {
|
|
13818
|
+
const { configJsonRef } = getCaddyConfig();
|
|
13812
13819
|
const proxies2 = Object.values(configJsonRef() || {});
|
|
13813
13820
|
if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
|
|
13814
13821
|
const ctx = validateTemplateContext({
|
|
@@ -13943,7 +13950,9 @@ ${line}
|
|
|
13943
13950
|
});
|
|
13944
13951
|
await unlink3(caddyLockFilePath).catch(() => {
|
|
13945
13952
|
});
|
|
13946
|
-
|
|
13953
|
+
if (caddyConfig) {
|
|
13954
|
+
await caddyConfig.cleanUp();
|
|
13955
|
+
}
|
|
13947
13956
|
} catch (e) {
|
|
13948
13957
|
consola.error(e);
|
|
13949
13958
|
}
|
package/dist/esbuild.cjs
CHANGED
|
@@ -13437,10 +13437,11 @@ var Liquid = class _Liquid {
|
|
|
13437
13437
|
// src/caddy/caddyfile.ts
|
|
13438
13438
|
var ProxyType = type({
|
|
13439
13439
|
target: "string",
|
|
13440
|
-
|
|
13440
|
+
portSuffix: "string",
|
|
13441
13441
|
tls: "string",
|
|
13442
13442
|
source: "string",
|
|
13443
|
-
base: "string"
|
|
13443
|
+
base: "string",
|
|
13444
|
+
healthCheck: "boolean"
|
|
13444
13445
|
});
|
|
13445
13446
|
var CaddyContext = type({
|
|
13446
13447
|
caddy_root: "string",
|
|
@@ -13476,9 +13477,9 @@ var caddyTemplate = `{
|
|
|
13476
13477
|
}
|
|
13477
13478
|
|
|
13478
13479
|
{% for p in proxies %}
|
|
13479
|
-
{{ p.target }}{{ p.
|
|
13480
|
+
{{ p.target }}{{ p.portSuffix }} {
|
|
13480
13481
|
{{ p.tls }}
|
|
13481
|
-
reverse_proxy http://{{ p.source }} {
|
|
13482
|
+
reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
|
|
13482
13483
|
health_uri {{ p.base }}
|
|
13483
13484
|
health_interval 2s
|
|
13484
13485
|
health_timeout 5s
|
|
@@ -13486,11 +13487,6 @@ var caddyTemplate = `{
|
|
|
13486
13487
|
unhealthy_status 502 503 504 404
|
|
13487
13488
|
lb_try_duration 3s
|
|
13488
13489
|
lb_try_interval 300ms
|
|
13489
|
-
health_headers {
|
|
13490
|
-
Accept text/html
|
|
13491
|
-
Accept-Encoding gzip, deflate, br
|
|
13492
|
-
User-Agent Caddy-Health-Check
|
|
13493
|
-
}
|
|
13494
13490
|
|
|
13495
13491
|
@error status 502 503 504 404
|
|
13496
13492
|
handle_response @error {
|
|
@@ -13500,6 +13496,7 @@ var caddyTemplate = `{
|
|
|
13500
13496
|
}
|
|
13501
13497
|
}
|
|
13502
13498
|
}
|
|
13499
|
+
{% endif %}
|
|
13503
13500
|
}
|
|
13504
13501
|
{% endfor %}
|
|
13505
13502
|
`;
|
|
@@ -13644,7 +13641,7 @@ var supportList = [
|
|
|
13644
13641
|
// src/caddy/config.ts
|
|
13645
13642
|
function useCaddyConfig() {
|
|
13646
13643
|
const configContentRef = signal("{}");
|
|
13647
|
-
const
|
|
13644
|
+
const configJsonRef = computed(() => {
|
|
13648
13645
|
try {
|
|
13649
13646
|
return JSON.parse(configContentRef());
|
|
13650
13647
|
} catch {
|
|
@@ -13667,26 +13664,26 @@ function useCaddyConfig() {
|
|
|
13667
13664
|
const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
|
|
13668
13665
|
setConfigContent();
|
|
13669
13666
|
});
|
|
13670
|
-
function
|
|
13671
|
-
const proxies =
|
|
13667
|
+
function writeCaddyConfig(_proxies) {
|
|
13668
|
+
const proxies = configJsonRef() || {};
|
|
13672
13669
|
_proxies.forEach((p) => {
|
|
13673
|
-
const index = `${p.target}${p.
|
|
13670
|
+
const index = `${p.target}${p.portSuffix}`;
|
|
13674
13671
|
proxies[index] = p;
|
|
13675
13672
|
});
|
|
13676
13673
|
const content = JSON.stringify(proxies, null, 2);
|
|
13677
13674
|
configContentRef(content);
|
|
13678
13675
|
return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
|
|
13679
13676
|
}
|
|
13680
|
-
async function
|
|
13677
|
+
async function cleanUp() {
|
|
13681
13678
|
await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
|
|
13682
13679
|
});
|
|
13683
13680
|
configContentRef("{}");
|
|
13684
13681
|
watchCaddyConfig.close();
|
|
13685
13682
|
}
|
|
13686
13683
|
return {
|
|
13687
|
-
configJsonRef
|
|
13688
|
-
writeCaddyConfig
|
|
13689
|
-
cleanUp
|
|
13684
|
+
configJsonRef,
|
|
13685
|
+
writeCaddyConfig,
|
|
13686
|
+
cleanUp
|
|
13690
13687
|
};
|
|
13691
13688
|
}
|
|
13692
13689
|
|
|
@@ -13820,7 +13817,13 @@ function testCaddy() {
|
|
|
13820
13817
|
});
|
|
13821
13818
|
});
|
|
13822
13819
|
}
|
|
13823
|
-
var
|
|
13820
|
+
var caddyConfig;
|
|
13821
|
+
function getCaddyConfig() {
|
|
13822
|
+
if (!caddyConfig) {
|
|
13823
|
+
caddyConfig = useCaddyConfig();
|
|
13824
|
+
}
|
|
13825
|
+
return caddyConfig;
|
|
13826
|
+
}
|
|
13824
13827
|
var CaddyInstant = class {
|
|
13825
13828
|
constructor() {
|
|
13826
13829
|
this.inited = false;
|
|
@@ -13872,7 +13875,8 @@ var CaddyInstant = class {
|
|
|
13872
13875
|
restore = true,
|
|
13873
13876
|
base = "/",
|
|
13874
13877
|
showCaddyLog = false,
|
|
13875
|
-
https = false
|
|
13878
|
+
https = false,
|
|
13879
|
+
healthCheck = true
|
|
13876
13880
|
} = options || {};
|
|
13877
13881
|
this._source = source;
|
|
13878
13882
|
this._target = target;
|
|
@@ -13885,15 +13889,18 @@ var CaddyInstant = class {
|
|
|
13885
13889
|
const proxies = [
|
|
13886
13890
|
{
|
|
13887
13891
|
target: targetHost,
|
|
13888
|
-
|
|
13892
|
+
portSuffix: https ? "" : ":80",
|
|
13889
13893
|
tls: https ? "tls internal" : "",
|
|
13890
13894
|
source,
|
|
13891
|
-
base
|
|
13895
|
+
base,
|
|
13896
|
+
healthCheck
|
|
13892
13897
|
}
|
|
13893
13898
|
];
|
|
13899
|
+
const { writeCaddyConfig } = getCaddyConfig();
|
|
13894
13900
|
writeCaddyConfig(proxies);
|
|
13895
13901
|
this._stopEffects.push(
|
|
13896
13902
|
effect(async () => {
|
|
13903
|
+
const { configJsonRef } = getCaddyConfig();
|
|
13897
13904
|
const proxies2 = Object.values(configJsonRef() || {});
|
|
13898
13905
|
if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
|
|
13899
13906
|
const ctx = validateTemplateContext({
|
|
@@ -14028,7 +14035,9 @@ ${line}
|
|
|
14028
14035
|
});
|
|
14029
14036
|
await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
|
|
14030
14037
|
});
|
|
14031
|
-
|
|
14038
|
+
if (caddyConfig) {
|
|
14039
|
+
await caddyConfig.cleanUp();
|
|
14040
|
+
}
|
|
14032
14041
|
} catch (e) {
|
|
14033
14042
|
consola.error(e);
|
|
14034
14043
|
}
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -13437,10 +13437,11 @@ var Liquid = class _Liquid {
|
|
|
13437
13437
|
// src/caddy/caddyfile.ts
|
|
13438
13438
|
var ProxyType = type({
|
|
13439
13439
|
target: "string",
|
|
13440
|
-
|
|
13440
|
+
portSuffix: "string",
|
|
13441
13441
|
tls: "string",
|
|
13442
13442
|
source: "string",
|
|
13443
|
-
base: "string"
|
|
13443
|
+
base: "string",
|
|
13444
|
+
healthCheck: "boolean"
|
|
13444
13445
|
});
|
|
13445
13446
|
var CaddyContext = type({
|
|
13446
13447
|
caddy_root: "string",
|
|
@@ -13476,9 +13477,9 @@ var caddyTemplate = `{
|
|
|
13476
13477
|
}
|
|
13477
13478
|
|
|
13478
13479
|
{% for p in proxies %}
|
|
13479
|
-
{{ p.target }}{{ p.
|
|
13480
|
+
{{ p.target }}{{ p.portSuffix }} {
|
|
13480
13481
|
{{ p.tls }}
|
|
13481
|
-
reverse_proxy http://{{ p.source }} {
|
|
13482
|
+
reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
|
|
13482
13483
|
health_uri {{ p.base }}
|
|
13483
13484
|
health_interval 2s
|
|
13484
13485
|
health_timeout 5s
|
|
@@ -13486,11 +13487,6 @@ var caddyTemplate = `{
|
|
|
13486
13487
|
unhealthy_status 502 503 504 404
|
|
13487
13488
|
lb_try_duration 3s
|
|
13488
13489
|
lb_try_interval 300ms
|
|
13489
|
-
health_headers {
|
|
13490
|
-
Accept text/html
|
|
13491
|
-
Accept-Encoding gzip, deflate, br
|
|
13492
|
-
User-Agent Caddy-Health-Check
|
|
13493
|
-
}
|
|
13494
13490
|
|
|
13495
13491
|
@error status 502 503 504 404
|
|
13496
13492
|
handle_response @error {
|
|
@@ -13500,6 +13496,7 @@ var caddyTemplate = `{
|
|
|
13500
13496
|
}
|
|
13501
13497
|
}
|
|
13502
13498
|
}
|
|
13499
|
+
{% endif %}
|
|
13503
13500
|
}
|
|
13504
13501
|
{% endfor %}
|
|
13505
13502
|
`;
|
|
@@ -13644,7 +13641,7 @@ var supportList = [
|
|
|
13644
13641
|
// src/caddy/config.ts
|
|
13645
13642
|
function useCaddyConfig() {
|
|
13646
13643
|
const configContentRef = signal("{}");
|
|
13647
|
-
const
|
|
13644
|
+
const configJsonRef = computed(() => {
|
|
13648
13645
|
try {
|
|
13649
13646
|
return JSON.parse(configContentRef());
|
|
13650
13647
|
} catch {
|
|
@@ -13667,26 +13664,26 @@ function useCaddyConfig() {
|
|
|
13667
13664
|
const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
|
|
13668
13665
|
setConfigContent();
|
|
13669
13666
|
});
|
|
13670
|
-
function
|
|
13671
|
-
const proxies =
|
|
13667
|
+
function writeCaddyConfig(_proxies) {
|
|
13668
|
+
const proxies = configJsonRef() || {};
|
|
13672
13669
|
_proxies.forEach((p) => {
|
|
13673
|
-
const index = `${p.target}${p.
|
|
13670
|
+
const index = `${p.target}${p.portSuffix}`;
|
|
13674
13671
|
proxies[index] = p;
|
|
13675
13672
|
});
|
|
13676
13673
|
const content = JSON.stringify(proxies, null, 2);
|
|
13677
13674
|
configContentRef(content);
|
|
13678
13675
|
return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
|
|
13679
13676
|
}
|
|
13680
|
-
async function
|
|
13677
|
+
async function cleanUp() {
|
|
13681
13678
|
await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
|
|
13682
13679
|
});
|
|
13683
13680
|
configContentRef("{}");
|
|
13684
13681
|
watchCaddyConfig.close();
|
|
13685
13682
|
}
|
|
13686
13683
|
return {
|
|
13687
|
-
configJsonRef
|
|
13688
|
-
writeCaddyConfig
|
|
13689
|
-
cleanUp
|
|
13684
|
+
configJsonRef,
|
|
13685
|
+
writeCaddyConfig,
|
|
13686
|
+
cleanUp
|
|
13690
13687
|
};
|
|
13691
13688
|
}
|
|
13692
13689
|
|
|
@@ -13820,7 +13817,13 @@ function testCaddy() {
|
|
|
13820
13817
|
});
|
|
13821
13818
|
});
|
|
13822
13819
|
}
|
|
13823
|
-
var
|
|
13820
|
+
var caddyConfig;
|
|
13821
|
+
function getCaddyConfig() {
|
|
13822
|
+
if (!caddyConfig) {
|
|
13823
|
+
caddyConfig = useCaddyConfig();
|
|
13824
|
+
}
|
|
13825
|
+
return caddyConfig;
|
|
13826
|
+
}
|
|
13824
13827
|
var CaddyInstant = class {
|
|
13825
13828
|
constructor() {
|
|
13826
13829
|
this.inited = false;
|
|
@@ -13872,7 +13875,8 @@ var CaddyInstant = class {
|
|
|
13872
13875
|
restore = true,
|
|
13873
13876
|
base = "/",
|
|
13874
13877
|
showCaddyLog = false,
|
|
13875
|
-
https = false
|
|
13878
|
+
https = false,
|
|
13879
|
+
healthCheck = true
|
|
13876
13880
|
} = options || {};
|
|
13877
13881
|
this._source = source;
|
|
13878
13882
|
this._target = target;
|
|
@@ -13885,15 +13889,18 @@ var CaddyInstant = class {
|
|
|
13885
13889
|
const proxies = [
|
|
13886
13890
|
{
|
|
13887
13891
|
target: targetHost,
|
|
13888
|
-
|
|
13892
|
+
portSuffix: https ? "" : ":80",
|
|
13889
13893
|
tls: https ? "tls internal" : "",
|
|
13890
13894
|
source,
|
|
13891
|
-
base
|
|
13895
|
+
base,
|
|
13896
|
+
healthCheck
|
|
13892
13897
|
}
|
|
13893
13898
|
];
|
|
13899
|
+
const { writeCaddyConfig } = getCaddyConfig();
|
|
13894
13900
|
writeCaddyConfig(proxies);
|
|
13895
13901
|
this._stopEffects.push(
|
|
13896
13902
|
effect(async () => {
|
|
13903
|
+
const { configJsonRef } = getCaddyConfig();
|
|
13897
13904
|
const proxies2 = Object.values(configJsonRef() || {});
|
|
13898
13905
|
if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
|
|
13899
13906
|
const ctx = validateTemplateContext({
|
|
@@ -14028,7 +14035,9 @@ ${line}
|
|
|
14028
14035
|
});
|
|
14029
14036
|
await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
|
|
14030
14037
|
});
|
|
14031
|
-
|
|
14038
|
+
if (caddyConfig) {
|
|
14039
|
+
await caddyConfig.cleanUp();
|
|
14040
|
+
}
|
|
14032
14041
|
} catch (e) {
|
|
14033
14042
|
consola.error(e);
|
|
14034
14043
|
}
|
package/dist/index.js
CHANGED
package/dist/nuxt.cjs
CHANGED
|
@@ -13438,10 +13438,11 @@ var Liquid = class _Liquid {
|
|
|
13438
13438
|
// src/caddy/caddyfile.ts
|
|
13439
13439
|
var ProxyType = type({
|
|
13440
13440
|
target: "string",
|
|
13441
|
-
|
|
13441
|
+
portSuffix: "string",
|
|
13442
13442
|
tls: "string",
|
|
13443
13443
|
source: "string",
|
|
13444
|
-
base: "string"
|
|
13444
|
+
base: "string",
|
|
13445
|
+
healthCheck: "boolean"
|
|
13445
13446
|
});
|
|
13446
13447
|
var CaddyContext = type({
|
|
13447
13448
|
caddy_root: "string",
|
|
@@ -13477,9 +13478,9 @@ var caddyTemplate = `{
|
|
|
13477
13478
|
}
|
|
13478
13479
|
|
|
13479
13480
|
{% for p in proxies %}
|
|
13480
|
-
{{ p.target }}{{ p.
|
|
13481
|
+
{{ p.target }}{{ p.portSuffix }} {
|
|
13481
13482
|
{{ p.tls }}
|
|
13482
|
-
reverse_proxy http://{{ p.source }} {
|
|
13483
|
+
reverse_proxy http://{{ p.source }} {% if p.healthCheck %} {
|
|
13483
13484
|
health_uri {{ p.base }}
|
|
13484
13485
|
health_interval 2s
|
|
13485
13486
|
health_timeout 5s
|
|
@@ -13487,11 +13488,6 @@ var caddyTemplate = `{
|
|
|
13487
13488
|
unhealthy_status 502 503 504 404
|
|
13488
13489
|
lb_try_duration 3s
|
|
13489
13490
|
lb_try_interval 300ms
|
|
13490
|
-
health_headers {
|
|
13491
|
-
Accept text/html
|
|
13492
|
-
Accept-Encoding gzip, deflate, br
|
|
13493
|
-
User-Agent Caddy-Health-Check
|
|
13494
|
-
}
|
|
13495
13491
|
|
|
13496
13492
|
@error status 502 503 504 404
|
|
13497
13493
|
handle_response @error {
|
|
@@ -13501,6 +13497,7 @@ var caddyTemplate = `{
|
|
|
13501
13497
|
}
|
|
13502
13498
|
}
|
|
13503
13499
|
}
|
|
13500
|
+
{% endif %}
|
|
13504
13501
|
}
|
|
13505
13502
|
{% endfor %}
|
|
13506
13503
|
`;
|
|
@@ -13645,7 +13642,7 @@ var supportList = [
|
|
|
13645
13642
|
// src/caddy/config.ts
|
|
13646
13643
|
function useCaddyConfig() {
|
|
13647
13644
|
const configContentRef = signal("{}");
|
|
13648
|
-
const
|
|
13645
|
+
const configJsonRef = computed(() => {
|
|
13649
13646
|
try {
|
|
13650
13647
|
return JSON.parse(configContentRef());
|
|
13651
13648
|
} catch {
|
|
@@ -13668,26 +13665,26 @@ function useCaddyConfig() {
|
|
|
13668
13665
|
const watchCaddyConfig = (0, import_node_fs2.watch)(caddyConfigPath, () => {
|
|
13669
13666
|
setConfigContent();
|
|
13670
13667
|
});
|
|
13671
|
-
function
|
|
13672
|
-
const proxies =
|
|
13668
|
+
function writeCaddyConfig(_proxies) {
|
|
13669
|
+
const proxies = configJsonRef() || {};
|
|
13673
13670
|
_proxies.forEach((p) => {
|
|
13674
|
-
const index = `${p.target}${p.
|
|
13671
|
+
const index = `${p.target}${p.portSuffix}`;
|
|
13675
13672
|
proxies[index] = p;
|
|
13676
13673
|
});
|
|
13677
13674
|
const content = JSON.stringify(proxies, null, 2);
|
|
13678
13675
|
configContentRef(content);
|
|
13679
13676
|
return (0, import_node_fs2.writeFileSync)(caddyConfigPath, content);
|
|
13680
13677
|
}
|
|
13681
|
-
async function
|
|
13678
|
+
async function cleanUp() {
|
|
13682
13679
|
await (0, import_promises2.unlink)(caddyConfigPath).catch(() => {
|
|
13683
13680
|
});
|
|
13684
13681
|
configContentRef("{}");
|
|
13685
13682
|
watchCaddyConfig.close();
|
|
13686
13683
|
}
|
|
13687
13684
|
return {
|
|
13688
|
-
configJsonRef
|
|
13689
|
-
writeCaddyConfig
|
|
13690
|
-
cleanUp
|
|
13685
|
+
configJsonRef,
|
|
13686
|
+
writeCaddyConfig,
|
|
13687
|
+
cleanUp
|
|
13691
13688
|
};
|
|
13692
13689
|
}
|
|
13693
13690
|
|
|
@@ -13821,7 +13818,13 @@ function testCaddy() {
|
|
|
13821
13818
|
});
|
|
13822
13819
|
});
|
|
13823
13820
|
}
|
|
13824
|
-
var
|
|
13821
|
+
var caddyConfig;
|
|
13822
|
+
function getCaddyConfig() {
|
|
13823
|
+
if (!caddyConfig) {
|
|
13824
|
+
caddyConfig = useCaddyConfig();
|
|
13825
|
+
}
|
|
13826
|
+
return caddyConfig;
|
|
13827
|
+
}
|
|
13825
13828
|
var CaddyInstant = class {
|
|
13826
13829
|
constructor() {
|
|
13827
13830
|
this.inited = false;
|
|
@@ -13873,7 +13876,8 @@ var CaddyInstant = class {
|
|
|
13873
13876
|
restore = true,
|
|
13874
13877
|
base = "/",
|
|
13875
13878
|
showCaddyLog = false,
|
|
13876
|
-
https = false
|
|
13879
|
+
https = false,
|
|
13880
|
+
healthCheck = true
|
|
13877
13881
|
} = options || {};
|
|
13878
13882
|
this._source = source;
|
|
13879
13883
|
this._target = target;
|
|
@@ -13886,15 +13890,18 @@ var CaddyInstant = class {
|
|
|
13886
13890
|
const proxies = [
|
|
13887
13891
|
{
|
|
13888
13892
|
target: targetHost,
|
|
13889
|
-
|
|
13893
|
+
portSuffix: https ? "" : ":80",
|
|
13890
13894
|
tls: https ? "tls internal" : "",
|
|
13891
13895
|
source,
|
|
13892
|
-
base
|
|
13896
|
+
base,
|
|
13897
|
+
healthCheck
|
|
13893
13898
|
}
|
|
13894
13899
|
];
|
|
13900
|
+
const { writeCaddyConfig } = getCaddyConfig();
|
|
13895
13901
|
writeCaddyConfig(proxies);
|
|
13896
13902
|
this._stopEffects.push(
|
|
13897
13903
|
effect(async () => {
|
|
13904
|
+
const { configJsonRef } = getCaddyConfig();
|
|
13898
13905
|
const proxies2 = Object.values(configJsonRef() || {});
|
|
13899
13906
|
if (!(this.caddyfile || "").includes(`${target.split(":")[0]}${https ? "" : ":80"}`)) {
|
|
13900
13907
|
const ctx = validateTemplateContext({
|
|
@@ -14029,7 +14036,9 @@ ${line}
|
|
|
14029
14036
|
});
|
|
14030
14037
|
await (0, import_promises3.unlink)(caddyLockFilePath).catch(() => {
|
|
14031
14038
|
});
|
|
14032
|
-
|
|
14039
|
+
if (caddyConfig) {
|
|
14040
|
+
await caddyConfig.cleanUp();
|
|
14041
|
+
}
|
|
14033
14042
|
} catch (e) {
|
|
14034
14043
|
consola.error(e);
|
|
14035
14044
|
}
|