1

i currently have configuration where i have apache running on port 80 and 443 and node js running on port 8000. Following this answer I have enabled node to respond on url https://www.example.com/node

ProxyPass /node http://localhost:8000

this works fine for most basic node js usage but while using custom peerJS server for websocket connection using following code

Server.js

const fs = require('fs');
const { PeerServer } = require('peer');
const peerServer = PeerServer({
    port: 8000,
    path: '/ps',
});
peerServer.on('connection', (client) => {
    console.log(client)
});

Client.js

var peer = new Peer('user',{
  host: 'www.example.com',
  port: 80,
  path: '/node/ps'
}); 

it is giving me error

Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR

and if i try using port 443 in client.js it shows:

Error during WebSocket handshake: Unexpected response code: 503

my vitualhost file is:

<VirtualHost *:443>
        ServerAdmin www.example.com
        DocumentRoot /var/www/html

        SSLEngine on


        SSLCertificateKeyFile /path/to/.key
        SSLCertificateFile /path/to/crt/file
        SSLCertificateChainFile /path/to/ca/bundle

  RewriteEngine on
  RewriteCond %{REQUEST_URI}  ^node          [NC]
  RewriteRule .* "wss:/localhost:8000/$1" [P,L]

  ProxyPass /node https://localhost:8000/
  ProxyPassReverse /node https://localhost:8000/

        <Directory /var/www/html/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        Header set Access-Control-Allow-Origin "*"
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>

</VirtualHost>
user7845429
  • 103
  • 1
  • 8

0 Answers0