forked from holy-unblocker/rammerhead
-
Notifications
You must be signed in to change notification settings - Fork 14
/
holy-config.js
71 lines (54 loc) · 2.08 KB
/
holy-config.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
68
69
70
71
'use strict';
const cookie = require('cookie');
module.exports = {
//// HOSTING CONFIGURATION ////
bindingAddress: "127.0.0.1",
port: process.env.PORT,
crossDomainPort: null,
publicDir: null,
ssl: null,
// this function's return object will determine how the client url rewriting will work.
// set them differently from bindingAddress and port if rammerhead is being served
// from a reverse proxy.
getServerInfo: (req) => {
const { origin_proxy } = cookie.parse(req.headers.cookie || '');
let origin;
try {
origin = new URL(origin_proxy);
} catch (error) {
origin = new URL(`${req.socket.encrypted ? 'https:' : 'http:'}//${req.headers.host}`);
}
const { hostname, port, protocol } = origin;
return {
hostname,
port,
crossDomainPort: port,
protocol
};
},
password: null,
// disable or enable localStorage sync (turn off if clients send over huge localStorage data, resulting in huge memory usages)
disableLocalStorageSync: false,
// restrict sessions to be only used per IP
restrictSessionToIP: true,
//// REWRITE HEADER CONFIGURATION ////
stripClientHeaders: [
'cf-ipcountry',
'cf-ray',
'x-forwarded-proto',
'cf-visitor',
'cf-connecting-ip',
'cdn-loop',
'x-forwarded-for'
],
rewriteServerHeaders: {
// you can also specify a function to modify/add the header using the original value (undefined if adding the header)
// 'x-frame-options': (originalHeaderValue) => '',
'x-frame-options': null // set to null to tell rammerhead that you want to delete it
},
//// LOGGING CONFIGURATION ////
// valid values: 'disabled', 'debug', 'traffic', 'info', 'warn', 'error'
generatePrefix: (level) => `[${new Date().toISOString()}] [${level.toUpperCase()}] `,
// logger depends on this value
getIP: (req) => (req.headers['x-forwarded-for'] || req.connection.remoteAddress || '').split(',')[0].trim()
};