This commit is contained in:
1 parent
454f1c9d6d
commit
8855d36684
7 files changed
+24
-6
No files matched your search
@@ -15,7 +15,7 @@ services:
|
||||
# playlist-URLs. Leeg laten om de Host-header van het request te gebruiken.
|
||||
# PUBLIC_URL: "http://192.168.0.123:8080"
|
||||
# LOG_REQUESTS: "1" # log elke (stream)request en status
|
||||
# PROXY_INSECURE_TLS: "1" # alleen nodig bij self-signed upstream-certificaten
|
||||
# PROXY_INSECURE_TLS: "1" # globale TLS-verificatie uitzetten; per entry kan ook "insecureTls": true
|
||||
volumes:
|
||||
- ./upstreams.json:/config/upstreams.json:ro
|
||||
restart: unless-stopped
|
||||
@@ -44,6 +44,15 @@ function readConfigEntries() {
|
||||
return;
|
||||
}
|
||||
|
||||
let insecureTls = false;
|
||||
if (item.insecureTls !== undefined) {
|
||||
if (typeof item.insecureTls !== 'boolean') {
|
||||
console.warn(`${label}: "insecureTls" must be a boolean, ignoring`);
|
||||
} else {
|
||||
insecureTls = item.insecureTls;
|
||||
}
|
||||
}
|
||||
|
||||
const validUrls = [];
|
||||
const seenUrls = new Set();
|
||||
urls.forEach((rawUrl, urlIndex) => {
|
||||
@@ -77,7 +86,7 @@ function readConfigEntries() {
|
||||
}
|
||||
|
||||
for (const url of validUrls) {
|
||||
entries.push({ url, username, password, entryId: index });
|
||||
entries.push({ url, username, password, entryId: index, insecureTls });
|
||||
}
|
||||
});
|
||||
return entries;
|
||||
|
||||
@@ -105,7 +105,7 @@ function probeUpstream(upstream) {
|
||||
'Accept-Encoding': 'identity',
|
||||
Connection: 'close',
|
||||
},
|
||||
rejectUnauthorized: settings.rejectUnauthorized,
|
||||
rejectUnauthorized: upstream.rejectUnauthorized,
|
||||
},
|
||||
(res) => {
|
||||
let body = '';
|
||||
|
||||
@@ -303,7 +303,7 @@ function handleProxy(req, res, reqUrl) {
|
||||
path: `${target.pathname}${target.search}`,
|
||||
method: req.method,
|
||||
headers,
|
||||
rejectUnauthorized: settings.rejectUnauthorized,
|
||||
rejectUnauthorized: upstream.rejectUnauthorized,
|
||||
},
|
||||
(proxyRes) => {
|
||||
settled = true;
|
||||
|
||||
@@ -84,6 +84,7 @@ function selectUpstream(exclude = new Set()) {
|
||||
function describeUpstream(upstream) {
|
||||
return {
|
||||
url: upstream.label,
|
||||
insecureTls: upstream.insecureTls,
|
||||
healthy: upstream.state.healthy,
|
||||
busy: isBusy(upstream),
|
||||
latencyMs: upstream.state.latencyMs,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { settings } = require('./settings');
|
||||
|
||||
function nowIso() {
|
||||
return new Date().toISOString();
|
||||
}
|
||||
@@ -19,7 +21,7 @@ function baseState() {
|
||||
}
|
||||
|
||||
class Upstream {
|
||||
constructor({ url, username, password, entryId }) {
|
||||
constructor({ url, username, password, entryId, insecureTls }) {
|
||||
const parsed = new URL(url);
|
||||
parsed.hash = '';
|
||||
parsed.search = '';
|
||||
@@ -28,10 +30,15 @@ class Upstream {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.entryId = entryId;
|
||||
this.insecureTls = insecureTls === true;
|
||||
this.key = `${parsed.origin}${this.basePath}|${username}|${password}`;
|
||||
this.state = { ...baseState(), inFlight: 0 };
|
||||
}
|
||||
|
||||
get rejectUnauthorized() {
|
||||
return this.insecureTls ? false : settings.rejectUnauthorized;
|
||||
}
|
||||
|
||||
get label() {
|
||||
return `${this.base.origin}${this.basePath}`;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
"https://panel2.example.com"
|
||||
],
|
||||
"username": "user2",
|
||||
"password": "pass2"
|
||||
"password": "pass2",
|
||||
"insecureTls": true
|
||||
}
|
||||
]
|
||||
Reference in new issue
Block a user