The websocket library I rely on ( PHP-Websockets ) does not yet support secure sockets ( wss
). My website is served over https
though, so I cannot use insecure ws
connections.
I'm trying to use Apache's mod_proxy
to forward the secure request that comes from the browser on to the client.
Javascript
var ws = new WebSocket('wss://example.com/_ws_/');
Apache VirtualHost
ProxyPass "/_ws_/" "ws://127.0.0.1:8080/"
ProxyPassReverse "/_ws_/" "ws://127.0.0.1:8080/"
# I've also tried "/_ws_/" "ws://example.com:8080/" Same error below
Upon trying to connect, the browser receives a 500 Server Error
. The logs show:
No protocol handler was valid for the URL /_ws_/. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
I've confirmed that if I remove the proxy rules, stop redirecting users to https
and try to connect to insecure sockets from the browser: new WebSocket('ws://example.com/')
, things work just fine.
My loaded Apache modules include mod_ssl.c
, mod_proxy.c
and mod_proxy_http.c
Apache 2.4
要反向代理 WebSockets,您还需要加载mod_proxy_wstunnel
模块。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.