Skip to content

Commit a7ba476

Browse files
author
Jean-Tiare Le Bigot
committed
added httpS support
1 parent be056a2 commit a7ba476

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

config.js

+19
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,32 @@
66
**
77
*/
88

9+
var fs = require('fs');
10+
911
var config = {
1012
add_proxy_header: true,//activate addition of X-Forwarded-For header for better logging on real server side
1113
allow_ip_list: './config/allow_ip_list',
1214
black_list: './config/black_list',
1315
host_filters: './config/hostfilters.js',
1416
listen:[{ip:'0.0.0.0', port:80},//all ipv4 interfaces
1517
{ip:'::', port:80}]//all ipv6 interfaces
18+
listen_ssl:[{
19+
ip:'0.0.0.0',//all *secure* ipv4 interfaces
20+
port:443,
21+
key:fs.readFileSync('/path/to/ssl.key'),
22+
cert:fs.readFileSync('/path/to/ssl.crt'),
23+
ca:[fs.readFileSync('/path/to/ca.pem'),
24+
fs.readFileSync('/path/to/sub-ca.pem')]
25+
},{
26+
ip:'::',//all *secure* ipv6 interfaces
27+
port:443,
28+
key:fs.readFileSync('/path/to/ssl.key'),
29+
cert:fs.readFileSync('/path/to/ssl.crt'),
30+
ca:[fs.readFileSync('/path/to/ca.pem'),
31+
fs.readFileSync('/path/to/sub-ca.pem')]
32+
33+
}
34+
]
1635
};
1736

1837
exports.config = config;

proxy.js

+13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
var http = require('http'),
10+
https = require('https');
1011
util = require('util');
1112
fs = require('fs'),
1213
config = require('./config').config,
@@ -356,8 +357,20 @@ update_blacklist();
356357
update_iplist();
357358
update_hostfilters();
358359

360+
//http
359361
config.listen.forEach(function(listen){
360362
util.log("Starting reverse proxy server on port '" + listen.ip+':'+listen.port);
361363
http.createServer(server_cb).listen(listen.port, listen.ip);
362364
});
363365

366+
//httpS
367+
config.listen_ssl.forEach(function(listen){
368+
util.log("Starting *secure* reverse proxy server on port '" + listen.ip+':'+listen.port);
369+
var options = {
370+
cert: listen.cert,
371+
key: listen.key,
372+
ca: listen.ca
373+
}
374+
https.createServer(options, server_cb).listen(listen.port, listen.ip);
375+
});
376+

0 commit comments

Comments
 (0)