@abtnode/router-provider 1.16.13-beta-118c3420 → 1.16.13-beta-a83ad86d
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/lib/nginx/index.js +22 -0
- package/lib/util.js +8 -0
- package/package.json +6 -6
package/lib/nginx/index.js
CHANGED
|
@@ -220,6 +220,12 @@ class NginxProvider extends BaseProvider {
|
|
|
220
220
|
const certificate = findCertificate(certificates, domain);
|
|
221
221
|
|
|
222
222
|
const parsedServerName = parseServerName(domain);
|
|
223
|
+
if (!parsedServerName) {
|
|
224
|
+
logger.warn('invalid site, empty server name:', { site: JSON.stringify(site), domain, parsedServerName });
|
|
225
|
+
// eslint-disable-next-line no-continue
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
|
|
223
229
|
if (certificate) {
|
|
224
230
|
// HTTPS configurations
|
|
225
231
|
// update all certs to disk
|
|
@@ -379,6 +385,11 @@ class NginxProvider extends BaseProvider {
|
|
|
379
385
|
return;
|
|
380
386
|
}
|
|
381
387
|
|
|
388
|
+
if (type === ROUTING_RULE_TYPES.GENERAL_REWRITE) {
|
|
389
|
+
this._addRewriteTypeLocation(args);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
|
|
382
393
|
if (type === ROUTING_RULE_TYPES.GENERAL_PROXY) {
|
|
383
394
|
this._addGeneralProxyLocation(args);
|
|
384
395
|
return;
|
|
@@ -459,6 +470,7 @@ class NginxProvider extends BaseProvider {
|
|
|
459
470
|
type,
|
|
460
471
|
commonHeaders,
|
|
461
472
|
cacheGroup,
|
|
473
|
+
pageGroup,
|
|
462
474
|
}) {
|
|
463
475
|
server._add('location', concatPath(prefix, suffix));
|
|
464
476
|
|
|
@@ -482,6 +494,9 @@ class NginxProvider extends BaseProvider {
|
|
|
482
494
|
}
|
|
483
495
|
|
|
484
496
|
location._add('include', 'includes/proxy');
|
|
497
|
+
if (pageGroup) {
|
|
498
|
+
location._add('proxy_set_header', `X-Page-Group "${pageGroup}"`);
|
|
499
|
+
}
|
|
485
500
|
|
|
486
501
|
// kill cache
|
|
487
502
|
if (this.cacheEnabled === false) {
|
|
@@ -558,6 +573,13 @@ class NginxProvider extends BaseProvider {
|
|
|
558
573
|
}
|
|
559
574
|
}
|
|
560
575
|
|
|
576
|
+
_addRewriteTypeLocation({ server, url, prefix, suffix, corsAllowedOrigins, serverName }) {
|
|
577
|
+
server._add('location', concatPath(prefix, suffix));
|
|
578
|
+
const location = this._getLastLocation(server);
|
|
579
|
+
this._addCors({ location, corsAllowedOrigins, serverName });
|
|
580
|
+
location._add('rewrite', `^${prefix}(.*) ${url}$1 last`);
|
|
581
|
+
}
|
|
582
|
+
|
|
561
583
|
_addNotFoundLocation({ server, prefix, suffix }) {
|
|
562
584
|
server._add('location', concatPath(prefix, suffix));
|
|
563
585
|
const location = this._getLastLocation(server);
|
package/lib/util.js
CHANGED
|
@@ -72,6 +72,11 @@ const formatRoutingTable = (routingTable, onRule) => {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
(site.rules || []).forEach((x) => {
|
|
75
|
+
if (x.to.type === ROUTING_RULE_TYPES.COMPONENT) {
|
|
76
|
+
console.warn(`Rule type is dropped: ${x.to.type}`, x);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
75
80
|
const prefix = trimEndSlash(x.from.pathPrefix || '/');
|
|
76
81
|
const groupPrefix = trimEndSlash(x.from.groupPathPrefix || '/');
|
|
77
82
|
const suffix = trimEndSlash(x.from.pathSuffix || '');
|
|
@@ -87,6 +92,8 @@ const formatRoutingTable = (routingTable, onRule) => {
|
|
|
87
92
|
if (x.to.type === ROUTING_RULE_TYPES.REDIRECT) {
|
|
88
93
|
rule.redirectCode = x.to.redirectCode || 302;
|
|
89
94
|
rule.url = x.to.url;
|
|
95
|
+
} else if (x.to.type === ROUTING_RULE_TYPES.GENERAL_REWRITE) {
|
|
96
|
+
rule.url = x.to.url;
|
|
90
97
|
} else {
|
|
91
98
|
rule.port = +x.to.port;
|
|
92
99
|
rule.did = x.to.did;
|
|
@@ -95,6 +102,7 @@ const formatRoutingTable = (routingTable, onRule) => {
|
|
|
95
102
|
rule.target = trimEndSlash(normalizePathPrefix(x.to.target || '/'));
|
|
96
103
|
rule.targetPrefix = x.to.targetPrefix || '';
|
|
97
104
|
rule.services = x.services || [];
|
|
105
|
+
rule.pageGroup = x.to.pageGroup;
|
|
98
106
|
}
|
|
99
107
|
|
|
100
108
|
const tmpPath = concatPath(prefix, suffix);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abtnode/router-provider",
|
|
3
|
-
"version": "1.16.13-beta-
|
|
3
|
+
"version": "1.16.13-beta-a83ad86d",
|
|
4
4
|
"description": "Routing engine implementations for abt node",
|
|
5
5
|
"author": "polunzh <polunzh@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/ArcBlock/blocklet-server#readme",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"url": "https://github.com/ArcBlock/blocklet-server/issues"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@abtnode/constant": "1.16.13-beta-
|
|
36
|
-
"@abtnode/logger": "1.16.13-beta-
|
|
37
|
-
"@abtnode/router-templates": "1.16.13-beta-
|
|
38
|
-
"@abtnode/util": "1.16.13-beta-
|
|
35
|
+
"@abtnode/constant": "1.16.13-beta-a83ad86d",
|
|
36
|
+
"@abtnode/logger": "1.16.13-beta-a83ad86d",
|
|
37
|
+
"@abtnode/router-templates": "1.16.13-beta-a83ad86d",
|
|
38
|
+
"@abtnode/util": "1.16.13-beta-a83ad86d",
|
|
39
39
|
"@arcblock/http-proxy": "^1.19.1",
|
|
40
40
|
"axios": "^0.27.2",
|
|
41
41
|
"debug": "^4.3.4",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"bluebird": "^3.7.2",
|
|
61
61
|
"fs-extra": "^10.1.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "dc2a4f7d5b55da109ebf873d8aa4d24f27a088c9"
|
|
64
64
|
}
|