Add option to set server address (#80)

Since this server may run behind a reverse proxy like Nginx, it should be able to bind to localhost only rather than listening to the whole network.
This commit is contained in:
Alex Huang
2018-04-02 10:37:45 +10:00
committed by Roman Shtylman
parent 2a9bc27117
commit d7852a3dd1

View File

@@ -17,6 +17,10 @@ const argv = optimist
default: '80', default: '80',
describe: 'listen on this port for outside requests' describe: 'listen on this port for outside requests'
}) })
.options('address', {
default: '0.0.0.0',
describe: 'IP address to bind to'
})
.options('max-sockets', { .options('max-sockets', {
default: 10, default: 10,
describe: 'maximum number of tcp sockets each client is allowed to establish at one time (the tunnels)' describe: 'maximum number of tcp sockets each client is allowed to establish at one time (the tunnels)'
@@ -33,7 +37,7 @@ const server = require('../server')({
secure: argv.secure secure: argv.secure
}); });
server.listen(argv.port, () => { server.listen(argv.port, argv.address, () => {
debug('server listening on port: %d', server.address().port); debug('server listening on port: %d', server.address().port);
}); });