- Create a script in a new folder, perhaps called peer, and name the script something like "peerserver.js"
- Add this code to it:
var fs = require('fs');
var PeerServer = require('peer').PeerServer;
var server = PeerServer({
port: 9000,
ssl: {
key: fs.readFileSync('your.key'),
cert: fs.readFileSync('your.crt')
}
});
- Put the key file and crt file I gave you into the same folder and point to them in the above code (replace your.key and your.crt with the right files).
- Upload the entire folder to your digital ocean server
- Using terminal, ssh to your digital ocean server, go into the folder you just uploaded and install the peer module
npm install peer
- Then run the server
node peerserver.js
- In your web application you'll point to your server:
var peer = new Peer('sergio1',{host: 'YOURSERVER.itp.io', port: 9000, path: '/'});
- Make sure you have an on error so you can see any error messages
peer.on('error', function(err) {
console.log(err);
});
- If all works well, run it with forever.