New config option to use an external websocket server

pull/1/head
yflory 8 years ago
parent 47b437614e
commit 4aacd291b1

@ -50,6 +50,12 @@ module.exports = {
*/
//websocketPort: 3000,
/* if you want to run a different version of cryptpad but using the same websocket
* server, you should use the other server port as websocketPort and disable
* the websockets on that server
*/
//useExternalWebsocket: false,
/* If Cryptpad is proxied without using https, the server needs to know.
* Specify 'useSecureWebsockets: true' so that it can send
* Content Security Policy Headers that prevent http and https from mixing

@ -82,7 +82,7 @@ app.get('/api/config', function(req, res){
var host = req.headers.host.replace(/\:[0-9]+/, '');
res.setHeader('Content-Type', 'text/javascript');
res.send('define(' + JSON.stringify({
websocketPath: config.websocketPath,
websocketPath: config.useExternalWebsocket ? undefined : config.websocketPath,
websocketURL:'ws' + ((useSecureWebsockets) ? 's' : '') + '://' + host + ':' +
websocketPort + '/cryptpad_websocket',
}) + ');');
@ -95,6 +95,8 @@ httpServer.listen(config.httpPort,config.httpAddress,function(){
});
var wsConfig = { server: httpServer };
if(!config.useExternalWebsocket) {
if (websocketPort !== config.httpPort) {
console.log("setting up a new websocket server");
wsConfig = { port: websocketPort};
@ -103,3 +105,4 @@ var wsSrv = new WebSocketServer(wsConfig);
Storage.create(config, function (store) {
NetfluxSrv.run(store, wsSrv, config);
});
}

Loading…
Cancel
Save