@cloud-cli/px 4.0.0 → 4.0.1
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/README.md +2 -1
- package/dist/proxy-manager.js +11 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,6 +29,8 @@ All available options:
|
|
|
29
29
|
- `cors`: handle CORS request on proxy level. See notes below!
|
|
30
30
|
- `redirect`: if request comes as http, redirect to https
|
|
31
31
|
- `redirectUrl`: if provided, issues a `Location` header and terminates with status 302 instead of proxying a request
|
|
32
|
+
- `headers`: comma separated headers to set in the outbound connection, e.g. authorisation headers
|
|
33
|
+
- `authorization`: matches incoming request headers against this value. If strings match, requests can continue.
|
|
32
34
|
|
|
33
35
|
**Remove a proxy**
|
|
34
36
|
|
|
@@ -89,4 +91,3 @@ Every request has additional headers:
|
|
|
89
91
|
If a proxy is from 'https://foo.example.com' to 'http://localhost:1234', the header will be 'foo.example.com'
|
|
90
92
|
- x-forwarded-proto: 'http' or 'https', depends on the original request
|
|
91
93
|
- forwarded: the standard header with the same information as the other two above
|
|
92
|
-
|
package/dist/proxy-manager.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import { getStorage } from '@cloud-cli/cli';
|
|
1
|
+
import { getStorage, getConfig } from '@cloud-cli/cli';
|
|
2
2
|
import { ProxyEntry, ProxyServer, ProxySettings } from '@cloud-cli/proxy';
|
|
3
|
+
const defaultOptions = {
|
|
4
|
+
httpPort: 80,
|
|
5
|
+
httpsPort: 443,
|
|
6
|
+
certsFolder: process.env.PX_CERTS_FOLDER || '/etc/letsencrypt/live',
|
|
7
|
+
};
|
|
3
8
|
const domainNotSpecifiedError = new Error('Domain not specified');
|
|
4
9
|
const targetNotSpecifiedError = new Error('Target not specified');
|
|
10
|
+
const moduleConfig = await getConfig('px', defaultOptions);
|
|
5
11
|
const { set, remove, getAll } = getStorage('px');
|
|
6
12
|
const settings = new ProxySettings({
|
|
7
|
-
certificatesFolder:
|
|
13
|
+
certificatesFolder: moduleConfig.certsFolder,
|
|
8
14
|
certificateFile: 'fullchain.pem',
|
|
9
15
|
keyFile: 'privkey.pem',
|
|
16
|
+
httpPort: moduleConfig.httpPort,
|
|
17
|
+
httpsPort: moduleConfig.httpsPort,
|
|
10
18
|
});
|
|
11
19
|
const px = new ProxyServer(settings);
|
|
12
20
|
const emptyProxy = {
|
|
@@ -104,6 +112,6 @@ export class ProxyManager {
|
|
|
104
112
|
async findByDomainAndPath(string) {
|
|
105
113
|
const [domain, path = ''] = string.split('/');
|
|
106
114
|
const proxies = await getAll();
|
|
107
|
-
return proxies.filter(p => p.domain === domain && (!path || domain === path));
|
|
115
|
+
return proxies.filter((p) => p.domain === domain && (!path || domain === path));
|
|
108
116
|
}
|
|
109
117
|
}
|