-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
24 lines (23 loc) · 829 Bytes
/
server.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
var http = require('http'),
https = require('https'),
fs = require('fs'),
conf = require('./config'),
proxy = require('./proxy'),
port = conf.get('port'),
listen = conf.get('listen'),
createServer = function() {
var the_proxy = proxy(conf);
if (conf.get('ssl')) {
return https.createServer({
key: fs.readFileSync(__dirname + '/data/key.pem'),
cert: fs.readFileSync(__dirname + '/data/certificate.pem'),
ca: fs.readFileSync(__dirname + '/data/cacert.pem'),
requestCert: false,
rejectUnauthorized: false
}, the_proxy);
} else {
return http.createServer(the_proxy);
}
};
console.log("Listening on: " + listen + ":" + port);
createServer().listen(port, listen);