@abtnode/router-provider 1.16.34-beta-20241205-145120-3a7aa096 → 1.16.34-beta-20241207-004652-f10ad343
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/includes/{proxy → proxy.raw} +10 -19
- package/lib/nginx/index.js +17 -0
- package/lib/nginx/util.js +1 -1
- package/package.json +6 -6
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
# DOC: http://nginx.org/en/docs/http/ngx_http_proxy_module.html
|
|
2
|
-
|
|
3
|
-
# TODO: 需要优先读取应用代码透传的 header
|
|
4
|
-
# proxy_hide_header Access-Control-Allow-Credentials;
|
|
5
|
-
# proxy_hide_header Vary;
|
|
6
|
-
# proxy_hide_header Access-Control-Allow-Origin;
|
|
7
|
-
# proxy_hide_header Access-Control-Allow-Methods;
|
|
8
|
-
|
|
9
|
-
proxy_set_header Host $host;
|
|
10
|
-
proxy_set_header X-Real-IP $remote_addr;
|
|
11
|
-
proxy_set_header X-Real-Uri $uri;
|
|
12
|
-
proxy_set_header X-Request-ID $request_id;
|
|
13
|
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
14
|
-
proxy_set_header X-Forwarded-Proto $scheme;
|
|
15
|
-
proxy_set_header X-Forwarded-Host $host;
|
|
16
|
-
proxy_set_header X-Forwarded-Port $server_port;
|
|
17
|
-
proxy_set_header Upgrade $http_upgrade;
|
|
18
|
-
proxy_set_header Connection $connection_upgrade;
|
|
19
|
-
|
|
20
1
|
proxy_connect_timeout 60;
|
|
21
2
|
proxy_read_timeout 3600;
|
|
22
3
|
proxy_send_timeout 3600;
|
|
@@ -30,3 +11,13 @@ proxy_redirect off;
|
|
|
30
11
|
proxy_http_version 1.1;
|
|
31
12
|
|
|
32
13
|
proxy_ignore_client_abort off;
|
|
14
|
+
|
|
15
|
+
proxy_set_header Host $host;
|
|
16
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
17
|
+
proxy_set_header X-Real-Uri $uri;
|
|
18
|
+
proxy_set_header X-Request-ID $request_id;
|
|
19
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
20
|
+
proxy_set_header Connection $connection_upgrade;
|
|
21
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
22
|
+
proxy_set_header X-Forwarded-Host $host;
|
|
23
|
+
proxy_set_header X-Forwarded-Port $server_port;
|
package/lib/nginx/index.js
CHANGED
|
@@ -201,6 +201,7 @@ class NginxProvider extends BaseProvider {
|
|
|
201
201
|
if (blockPolicy && blockPolicy?.enabled) {
|
|
202
202
|
this.updateBlacklist(blockPolicy.blacklist);
|
|
203
203
|
}
|
|
204
|
+
this.updateProxyPolicy(proxyPolicy);
|
|
204
205
|
|
|
205
206
|
const allRules = sites.reduce((acc, site) => {
|
|
206
207
|
acc.push(...(site.rules || []));
|
|
@@ -908,6 +909,22 @@ class NginxProvider extends BaseProvider {
|
|
|
908
909
|
fs.writeFileSync(blacklistFile, blacklist.map((x) => `${x} 1;`).join(os.EOL));
|
|
909
910
|
}
|
|
910
911
|
|
|
912
|
+
updateProxyPolicy(proxyPolicy) {
|
|
913
|
+
const proxyRaw = fs.readFileSync(path.join(this.includesDir, 'proxy.raw'), 'utf8');
|
|
914
|
+
const proxyPolicyFile = path.join(this.includesDir, 'proxy');
|
|
915
|
+
if (proxyPolicy?.enabled) {
|
|
916
|
+
fs.writeFileSync(
|
|
917
|
+
proxyPolicyFile,
|
|
918
|
+
[proxyRaw, 'proxy_set_header X-Forwarded-For "$http_x_forwarded_for,$realip_remote_addr";'].join(os.EOL)
|
|
919
|
+
);
|
|
920
|
+
} else {
|
|
921
|
+
fs.writeFileSync(
|
|
922
|
+
proxyPolicyFile,
|
|
923
|
+
[proxyRaw, 'proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;'].join(os.EOL)
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
911
928
|
getLogFilesForToday() {
|
|
912
929
|
return {
|
|
913
930
|
access: this.accessLog,
|
package/lib/nginx/util.js
CHANGED
|
@@ -226,7 +226,7 @@ real_ip_recursive ${proxyPolicy?.trustRecursive ? 'on' : 'off'};`
|
|
|
226
226
|
|
|
227
227
|
log_format compression '$remote_addr - $remote_user [$time_iso8601] $request_id '
|
|
228
228
|
'"$host" "$request" $status $body_bytes_sent '
|
|
229
|
-
'"$http_referer" "$http_user_agent" "$http_x_forwarded_for" '
|
|
229
|
+
'"$http_referer" "$http_user_agent" "${proxyPolicy?.enabled ? '$realip_remote_addr' : '$http_x_forwarded_for'}" '
|
|
230
230
|
'rt="$request_time" uid="$cookie_connected_did" uos="$cookie_connected_wallet_os" '
|
|
231
231
|
'uct="$upstream_connect_time" uht="$upstream_header_time" urt="$upstream_response_time"';
|
|
232
232
|
access_log ${path.join(logDir, 'access.log')} compression;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abtnode/router-provider",
|
|
3
|
-
"version": "1.16.34-beta-
|
|
3
|
+
"version": "1.16.34-beta-20241207-004652-f10ad343",
|
|
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.34-beta-
|
|
36
|
-
"@abtnode/logger": "1.16.34-beta-
|
|
37
|
-
"@abtnode/router-templates": "1.16.34-beta-
|
|
38
|
-
"@abtnode/util": "1.16.34-beta-
|
|
35
|
+
"@abtnode/constant": "1.16.34-beta-20241207-004652-f10ad343",
|
|
36
|
+
"@abtnode/logger": "1.16.34-beta-20241207-004652-f10ad343",
|
|
37
|
+
"@abtnode/router-templates": "1.16.34-beta-20241207-004652-f10ad343",
|
|
38
|
+
"@abtnode/util": "1.16.34-beta-20241207-004652-f10ad343",
|
|
39
39
|
"@arcblock/http-proxy": "^1.19.1",
|
|
40
40
|
"@arcblock/is-valid-domain": "^1.0.5",
|
|
41
41
|
"axios": "^1.7.5",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"bluebird": "^3.7.2",
|
|
60
60
|
"fs-extra": "^11.2.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "164559152125585db2b26864ecb627bd81b56a77"
|
|
63
63
|
}
|