通过apache

时间:2016-11-22 14:37:24

标签: apache ssl websocket

问题:如何通过apache隧道连接安全的websocket连接,以便可以通过标准的ssl端口提供页面和websocket?。

到目前为止,我的具体方案和尝试

我有一个用perl编写的后端,它通过安全的websockets(wss)与我的网站访问者(通过https使用apache)在一个单独的端口(在这种情况下为13300)进行通信。

为了防止防火墙等问题,我现在想为我的网站和websocket后端使用相同的端口。

根据我的发现,这应该可以在apache上使用mod proxy_wstunnel。

为此,我已将以下内容添加到我的apache default-ssl.conf

ProxyRequests Off
ProxyPass "/wss/" "https://localhost:13300/"
ProxyPassReverse "/wss/" "https://localhost:13300/"
ProxyPass "/wss/" "wss://localhost:13300/"
ProxyPassReverse "/wss/" "wsp://localhost:13300/"

并启用所需的mod:

a2enmod proxy
a2enmod proxy_wstunnel

我的网站用于连接到wss://domain.com:13300,现在使用wss://domain.com/wss

然而,查看浏览器的开发者控制台,从未建立连接:

WebSocket connection to 'wss://xxxxxxxxx.com/wss' failed: Error during WebSocket handshake: Unexpected response code: 404

查看apache错误日志(loglevel debug)

[ssl:info] [pid 19289] (70007)The timeout specified has expired: [client 192.168.100.1:58118] AH01991: SSL input filter read failed.
[ssl:debug] [pid 19289] ssl_engine_io.c(1003): [client 192.168.100.1:58118] AH02001: Connection closed to child 1 with standard shutdown (server xxxxxxxxxxx.com:443)

在后端的一侧,我从未看到任何连接到达那里的迹象。

额外信息:

服务器正在运行debian stable(写作时jessie)

Apache版本:

Server version: Apache/2.4.10 (Debian)  (Note: the proxy_wstunnel bug where ssl was dropped and plaintext used to speak to the backend should be fixed in this version)
Server built:   Sep 15 2016 20:44:43

backend使用perl v5.20.2,使用Net :: WebSocket :: Server和IO :: Socket :: SSL。

自签名证书用于连接。证书已添加到浏览器中,并且当后端仍在运行单独的端口时不会导致任何问题。

0 个答案:

没有答案