V
V
Valeri Lavrov2016-06-24 03:21:23
PHP
Valeri Lavrov, 2016-06-24 03:21:23

How to make nodejs, socket.io and PHP communicate over HTTPS?

The site itself is in PHP.
Nodejs accepts requests from socket.io and returns the number of connected users.
The problem is that he does not see the https request. And when you try to send an http request, while being on an https site, the socket starts swearing: "This request has been blocked; the content must be served over HTTPS."
Nodejs code example:

io.on('connection', function(socket) {
socket.emit('message', {
        type: 'logins',
        count: Object.size(io.sockets.connected)
      });
});

How to transfer this data to the site via https?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Grabko, 2016-06-24
@VGrabko

g.zeos.in/?q=socket.io%20https

D
Dmitry Belyaev, 2016-06-24
@bingo347

Option 1: wrap socket.io with the https module (they have a doc with examples), if the domain is the same, then you can use the same certificate as on the site
Option 2: proxy everything through nginx (a lot has been written about this too)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question