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.
Files changed (2) hide show
  1. package/kernel/caddy.js +40 -41
  2. 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
- if (chunks.length === 2) {
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
- let namespaced_url = chunks.join(".")
289
-
290
- const exposed_url = ip + ":" + INTERNAL_PORT
291
- console.log({ namespaced_url, https_domain, exposed_url, internal_ip })
292
- this.mapping[internal_ip] = namespaced_url
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": ip + ":PORT_PLACEHOLDER_" + INTERNAL_PORT }]
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "3.8.31",
3
+ "version": "3.8.32",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {