Answer the question
In order to leave comments, you need to log in
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)
});
});
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question