Search code examples
node.jssslexpresssails.jsports

How to create a sails.js app that will listen on two different ports simultaneously


For example, I have a sails.js application that (by default) listens on port 1337. I want to configure it to listen on two different ports at the same time - one for SSL and one for non-SSL traffic. Is this even possible? I have scoured the documentation and cannot find an example that shows me anything other than setting a single port value.

Do I have to create an front-end that (like Apache or nginx) to do it is it it possible to stick with a pure node.js solution - perhaps with express?

I should add that I am only using the server for web sockets via socket.io

A working example would be great, but any tips and pointers would help.


Solution

  • the simplest would probably be to run your server twice.

    Just make sure you share common data like sessions and persistent global variables - maybe using something like redis (sails can automatically base your session on redis and can even bind a model on the redis server while keeping the rest on your current database)