-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproxy.js
45 lines (39 loc) · 1.32 KB
/
proxy.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
var fs = require('fs'),
http = require('http'),
https = require('https'),
httpProxy = require('http-proxy')
environment = process.env.NODE_ENV || 'production'
config = require('./config.' + environment)
var options = {
https: {
key: fs.readFileSync(config.ssl.key, 'utf8'),
cert: fs.readFileSync(config.ssl.cert, 'utf8'),
ca: config.ssl.ca ? fs.readFileSync(config.ssl.ca, 'utf8') : null,
ciphers: 'ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:'
+ 'HIGH:!MD5:!aNULL:!EDH',
honorCipherOrder: true
},
enable: {
xforward: true // enables X-Forwarded-For
}
}
var proxy = new httpProxy.HttpProxy({
target: {
host: 'localhost',
port: config.app.port
},
enable: { xforward: true }
})
httpProxy.createServer(options, function (req, res) {
proxy.proxyRequest(req, res)
}).listen(443).on('upgrade', function (req, socket, head) {
proxy.proxyWebSocketRequest(req, socket, head);
})
var httpOptions = options
delete httpOptions.https
httpProxy.createServer(httpOptions, function (req, res) {
proxy.proxyRequest(req, res)
}).listen(80).on('upgrade', function (req, socket, head) {
proxy.proxyWebSocketRequest(req, socket, head);
})
console.log("Ready to proxy requests...")