This repository has been archived by the owner on Mar 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
/
proxy-conf-example.js
67 lines (57 loc) · 1.79 KB
/
proxy-conf-example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
const CLOUDSTACK_ENDPOINT = 'https://example.com';
/*
* Plugins endpoint
* https://github.com/bwsw/cloudstack-ui#plugins-supported
* */
const PULSE_PLUGIN_ENDPOINT = 'http://example.com:8081';
const WEBSHELL_PLUGIN_ENDPOINT = 'http://example.com:8082';
const httpAccessHelperPort = require('./projects/http-access-helper/config').port;
const HTTP_ACCESS_HELPER_ENDPOINT = `http://localhost:${httpAccessHelperPort}`;
function onProxyRes(proxyRes, req, res) {
var cookies = proxyRes.headers['set-cookie'];
var cookieRegex = /Secure/i;
if (cookies) {
var newCookie = cookies.map(function(cookie) {
if (cookieRegex.test(cookie)) {
return cookie.replace(cookieRegex, '');
}
return cookie;
});
delete proxyRes.headers['set-cookie'];
proxyRes.headers['set-cookie'] = newCookie;
}
}
const apiProxyConfig = {
context: ['/client/api', '/client/console'],
target: CLOUDSTACK_ENDPOINT,
secure: false,
};
// If server works over https need to change Secure Cookie
if (CLOUDSTACK_ENDPOINT.indexOf('https') === 0) {
apiProxyConfig.onProxyRes = onProxyRes;
}
const pulseProxyConfig = {
context: ['/cs-extensions/pulse/**'],
target: PULSE_PLUGIN_ENDPOINT,
secure: false,
pathRewrite: { '^/cs-extensions/pulse': '' },
};
const webShellProxyConfig = {
context: ['/cs-extensions/webshell/**'],
target: WEBSHELL_PLUGIN_ENDPOINT,
secure: false,
pathRewrite: { '^/cs-extensions/webshell': '' },
};
const httpAccessHelperProxyConfig = {
context: ['/cs-extensions/http-access-helper/**'],
target: HTTP_ACCESS_HELPER_ENDPOINT,
secure: false,
pathRewrite: { '^/cs-extensions/http-access-helper': '' },
};
const PROXY_CONFIG = [
apiProxyConfig,
// pulseProxyConfig,
// webShellProxyConfig,
// httpAccessHelperProxyConfig,
];
module.exports = PROXY_CONFIG;