Nodejs - secure https site

Are there any plans to modify server.js so it will function on secure sites as well?

Or should I hack server.js myself, and whatever else :open_mouth:


Modifying server.js for a secure site is quite easy:

  • Study this:

  • And make the appropriate changes:

    • Change http to https
    • Add options to 2 places:

    var options = {
    //I’m using IIS, and thus am working with a .pfx file, use the separate .pem files for Apache
    pfx: fs.readFileSync(’.pfx’),
    //In my case I needed to add a password, you might not need to
    passphrase: ‘’

    var server = https.createServer(options,function(request, response){

Note that I changed posix to fs.

I was new to the nodejs documentation. https is a subclass of tls. You need to read to get the whole picture - this is where I found the passphrase info. You might need some other options at your end.

Hope this helps someone.

Is it possible to use dhtmlx live update features using node.js while having a php website ?

You will need nodejs installation in any case.
All data loading and data saving logic can be written in the php, but you need nodejs for websockets(notifications) handling.

Thanks Stanislav.

The purpose would be to use good php scripts that may eventually include some dhtmlx live update so as you mention so all data loading and data saving logic can be written in the php.


outside of the php scripts, the main development part would be made with a node.js framework,
Derby to be precise, a framework to write realtime, collaborative applications that run in both Node.js and browsers.

No objection ? :slight_smile:

Sounds as a good plan :slight_smile:

The first eventual problem i think about is by running apache / nginx for php, it listens on port 80 and the idea to rely on another port for node.js is not sexy enough to seduce me :slight_smile:.

I’m about to follow this approach … -together/, ie using same port for both php and node.js. Still have to find the same step by step approach for nginx and i should be on track.

How do you generally manage things on your side ? Do you see drawbacks in the mentioned approach above in a cluster environment ?

The second point is PHP / node.js interaction. I hesitate between these approachs :

  • Dnode in php like explained here … ethr-dnode

  • use a message-passing system such as Gearman.

  • Redis Pub/Sub with PHP driver for Redis and pushing things that’s happening in PHP application in to the channel and in Node.js do whatever you want by listening to those channels.

  • i don’t know if it’s a joke but there is a PHP module for Node.js, basically it uses Node.js to serve PHP

What is the strategy on your side to handle this interaction ? ie how do you generally deal this this ?

You can use the same port but different subdomain ( web-sockets are not affected by cross domain limitations ). In such case you can route requests by nginx, based on the requested domain.

Also, you need not to communicate between nodejs and php.

  • client sends info to php
  • data saved in db
  • client get saving callback and send message by websocket to the nodejs server
  • nodejs server inform all clients about update
  • all clients get latest data

As you can see the client communicate with both php and nodejs, but there is no need to server side communication between two services.

Good idea Stanislav, i were thinking about subdomains too.