0

What I have

I have Socket.IO app letteraly from template

const express = require('express');
const app = express();
const http = require('http');
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);

io.on('connection', (socket) => {
  console.log('a user connected');
});

server.listen(3000, () => {
  console.log('listening on *:3000');
});

And I configured Apache

<VirtualHost *:443>
  ServerName ws.domain.com
 
  ProxyPreserveHost On
  ProxyPass / http://127.0.0.1:3000/
  ProxyPassReverse / http://127.0.0.1:3000/

  SSLEngine on
  SSLCertificateFile /root/origin.pem
  SSLCertificateKeyFile /root/private.key
</VirtualHost>

When I try to send request via Postman to localhost:3000 everything works

enter image description here

enter image description here

But when I try to send request to ws.domain.com I always get 400 Bad Request

enter image description here

enter image description here

What I tried

  1. I tried to configure Apache from docs this does not helped me
  2. I tried to use Nginx and I configured it from docs its also does not helped me
  3. I tried to rewrite server on Flask with PySocketIO and also with flask-socketio, and get same error

I am already completely desperate and do not understand what the problem is.

P.S. If this can be important, I use CentOS 7. I proxy the domain through the Cloudflare and there the websockets are of course connected

P.S.S. All my other HTTP applications on the server work correctly (via Apache), the problem is only in websockets

RoyalGoose
  • 103
  • 5

1 Answers1

0

The answer turned out to be very prosaic. As it turned out, the front-end had version 2 of Socket.IO, and on the server 4. Upgrading the packages helped to solve the problem

RoyalGoose
  • 103
  • 5