pinokiod 3.8.31 → 3.8.32
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/kernel/caddy.js +40 -41
- package/package.json +1 -1
package/kernel/caddy.js
CHANGED
|
@@ -281,52 +281,27 @@ class Caddy {
|
|
|
281
281
|
|
|
282
282
|
// insert the $account value right before the last part (1234.localhost => 1234.x.localhost)
|
|
283
283
|
let chunks = https_domain.split(".")
|
|
284
|
-
|
|
284
|
+
let namespaced_url
|
|
285
|
+
if (chunks.length === 3) {
|
|
286
|
+
namespaced_url = https_domain
|
|
287
|
+
} else if (chunks.length === 2) {
|
|
285
288
|
chunks.splice(chunks.length - 1, 0, account)
|
|
289
|
+
namespaced_url = chunks.join(".")
|
|
290
|
+
}
|
|
291
|
+
this.mapping[internal_ip] = namespaced_url
|
|
292
|
+
console.log({ namespaced_url, https_domain, exposed_url, internal_ip })
|
|
286
293
|
|
|
287
294
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
// create a proxy proxy
|
|
296
|
-
// 1. create an exposed port listening on 0.0.0.0
|
|
297
|
-
// 2. the exposed port points to the internal ip
|
|
298
|
-
payload.apps.http.servers[":" + INTERNAL_PORT] = {
|
|
299
|
-
"listen": [":PORT_PLACEHOLDER_" + INTERNAL_PORT],
|
|
300
|
-
"routes": [{
|
|
301
|
-
"handle": [
|
|
302
|
-
{
|
|
303
|
-
"handler": "reverse_proxy",
|
|
304
|
-
"upstreams": [{ "dial": internal_ip }]
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
"handler": "headers",
|
|
308
|
-
"response": {
|
|
309
|
-
"set": {
|
|
310
|
-
"Access-Control-Allow-Origin": ["*"],
|
|
311
|
-
"Access-Control-Allow-Methods": ["GET, POST, OPTIONS, PUT, DELETE"],
|
|
312
|
-
"Access-Control-Allow-Headers": ["*"],
|
|
313
|
-
"Vary": ["Origin"]
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
]
|
|
318
|
-
}]
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
// 1. point proxy URL to the 127.0.0.1:EXPOSED_PORT
|
|
322
|
-
payload.apps.http.servers.main.routes.push({
|
|
323
|
-
"match": [{
|
|
324
|
-
"host": [namespaced_url],
|
|
325
|
-
}],
|
|
295
|
+
// create a proxy proxy
|
|
296
|
+
// 1. create an exposed port listening on 0.0.0.0
|
|
297
|
+
// 2. the exposed port points to the internal ip
|
|
298
|
+
payload.apps.http.servers[":" + INTERNAL_PORT] = {
|
|
299
|
+
"listen": [":PORT_PLACEHOLDER_" + INTERNAL_PORT],
|
|
300
|
+
"routes": [{
|
|
326
301
|
"handle": [
|
|
327
302
|
{
|
|
328
303
|
"handler": "reverse_proxy",
|
|
329
|
-
"upstreams": [{ "dial":
|
|
304
|
+
"upstreams": [{ "dial": internal_ip }]
|
|
330
305
|
},
|
|
331
306
|
{
|
|
332
307
|
"handler": "headers",
|
|
@@ -340,8 +315,32 @@ class Caddy {
|
|
|
340
315
|
}
|
|
341
316
|
}
|
|
342
317
|
]
|
|
343
|
-
}
|
|
318
|
+
}]
|
|
344
319
|
}
|
|
320
|
+
|
|
321
|
+
// 1. point proxy URL to the 127.0.0.1:EXPOSED_PORT
|
|
322
|
+
payload.apps.http.servers.main.routes.push({
|
|
323
|
+
"match": [{
|
|
324
|
+
"host": [namespaced_url],
|
|
325
|
+
}],
|
|
326
|
+
"handle": [
|
|
327
|
+
{
|
|
328
|
+
"handler": "reverse_proxy",
|
|
329
|
+
"upstreams": [{ "dial": ip + ":PORT_PLACEHOLDER_" + INTERNAL_PORT }]
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
"handler": "headers",
|
|
333
|
+
"response": {
|
|
334
|
+
"set": {
|
|
335
|
+
"Access-Control-Allow-Origin": ["*"],
|
|
336
|
+
"Access-Control-Allow-Methods": ["GET, POST, OPTIONS, PUT, DELETE"],
|
|
337
|
+
"Access-Control-Allow-Headers": ["*"],
|
|
338
|
+
"Vary": ["Origin"]
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
]
|
|
343
|
+
})
|
|
345
344
|
}
|
|
346
345
|
}
|
|
347
346
|
return payload
|