I'm working on a WebRTC video conferencing/remote performance site (built on an AWS "Lightsail" VM), and I've run into a very odd issue with PeerJS.
I'm hosting my own PeerJS server on port 3001, via an Apache2 reverse proxy. The reverse proxy seems to work correctly, because when peerjs.min.js
hits '/peerjs/id'
it returns an ID as expected.
However, subsequent calls to '/peerjs'
that are made from inside the peerjs.min.js
file instantly return a 404 error.
(I should note that my site works correctly if I simply use the default PeerJS server.)
So, for example, this request works as expected:
https://peer.improv-stage.com/peerjs/id
While this follow up request (which again, is kicked off from inside peerjs.min.js
), results in a 404 error.
wss://peer.improv-stage.com/peerjs?key=peerjs&id=bd261271-09f7-44a3-a07e-3d3364c1989f&token=40sh9uviwb
(The id
and token
, parameters here are from a single invocation of the page, and will change on each visit, of course.)
I'm pretty sure it's a problem with my server setup, so, here's the info for that...
I'm invoking the Peer Server with the following command inside the htdocs
directory:
peerjs --port 3001 --proxied true
And it replies with:
Started PeerServer on ::, port: 3001, path: / (v. 0.6.1)
And here's the relevant vhosts config from apache:
<VirtualHost *:443>
ServerName peer.improv-stage.com
DocumentRoot "/opt/bitnami/apache/htdocs"
ProxyPass / http://127.0.0.1:3001/
ProxyPassReverse / http://127.0.0.1:3001/
SSLEngine on
SSLCertificateFile "/opt/bitnami/letsencrypt/certificates/improv-stage.com.crt"
SSLCertificateKeyFile "/opt/bitnami/letsencrypt/certificates/improv-stage.com.key"
<Directory "/opt/bitnami/apache/htdocs">
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Another thing to note is that this lives on the same server as the site "Improv Stage" site itself. The improv stage site is a NodeJS app and it invokes the peer server (on the client side), with the following:
var myPeer = new Peer(undefined, {
host: 'peer.improv-stage.com',
port: 443,
secure: true,
path: "/",
debug: 3
})
I'm thinking that the solution will be to spin up another VM just for the Peer Server, but this entire thing bugs me. It should work, shouldn't it?
In any case, the site is currently live as I write this, and I'll leave it up and running until at least a few of you have had a look at it and offer some feedback. You can reach it at:
https://www.improv-stage.com/stackoverflow
Thanks for any ideas you can offer!
Diz