R
R
Rinten2019-11-07 19:32:25
Apache HTTP Server
Rinten, 2019-11-07 19:32:25

How to set up proxying for wss websockets in Apache?

I took a socket chat https://kode-blog.io/websocket-server-php
I installed it on the hosting - everything is OK, it works fine. From chrome. And firefox does not want to connect to the server, it says it is not secure.

>The app itself is under SSL but the websocket being accessed is not. Chrome and Opera don't care but Firefox does.
According to: https://bugzilla.mozilla.org/show_bug.cgi?id=303952
This is known and is not considered a bug. Mozilla's response: wontfix

Ok, I found a solution (use a proxy on the server, the first answer is here: https://stackoverflow.com/questions/16979793/php-r... )
Installed both modules (mod_proxy.so and mod_proxy_wstunnel.so) in Apache. Added the line ProxyPass
/wss2/ ws://r.xxxxxxxxxxx.xxx:999/
to apache2.conf and
var websocket = new WebSocket('wss://r.xxxxxxxxxxx.xxx/wss2/') ;
(Port 999 is specially opened).
And it doesn't work. The browser throws "Uncaught TypeError: websocket is not a constructor" when trying to connect . I tried different options to write to the config and to the script, to no avail.
For example:
ProxyPass /wss2/ ws://localhost:999/
and
var websocket = new WebSocket("wss://localhost/wss2/");
And I do not understand where to look for the reason for not creating a socket.
websocket = new WebSocket('ws:127.0.0.1:999'); -that's how it successfully works on ws.
Server:
Ubuntu-18.04-amd64
Apache/2.4.29
PHP 7.2.24

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question