问题
我正在尝试在Apache服务器后面设置一个带有laravel websockets库的实时环境。Websockets服务器运行在端口6001
上(从外部无法访问)。Apache VHost配置为ws.example.com
我无法让Apache正确代理wss://
请求。对wss://ws.example.com/request/path?protocol=7&client=js&version=5.1.1&flash=false
的请求失败。(Error during WebSocket handshake: Invalid status line
)
我认为我的vhost配置有问题。我是否遗漏了什么?任何建议都将不胜感激。
虚拟主机配置
<VirtualHost *:443>
ServerName ws.example.com
ServerAlias www.ws.example.com.com
DocumentRoot /srv/vhost/example.com/domains/ws.example.com/public_html
ErrorLog /var/log/virtualmin/ws.example.com_error_log
CustomLog /var/log/virtualmin/ws.example.com_access_log combined
ScriptAlias /cgi-bin/ /srv/vhost/example.com/domains/ws.example.com/cgi-bin/
DirectoryIndex index.php index.html
RewriteEngine on
ProxyRequests off
ProxyVia on
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule /(.*) ws://localhost:6001/$1 [P,L]
ProxyPass /request/path http://localhost:6001/request/path
ProxyPassReverse /request/path http://localhost:6001/request/path
SSLCertificateFile /etc/letsencrypt/path/ws.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/path/ws.example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
2条答案
按热度按时间bvuwiixz1#
为websockets创建一个子域。然后编辑你的虚拟主机配置(Apache 2.4)如下。使用pusher-php-server 5.0.3
9rygscc12#
@max:你的重写规则是关键,也适用于当代理只是转发未加密的流量和apache是处理ssl到外面,取代
wss
与ws
然后-经过一天的摆弄它终于工作!编辑:没有足够的声誉发表评论,对不起