?Apache配置
<VirtualHost *:443>
ServerAdmin webmaster@example.com
#域名指向目录
DocumentRoot "/www/wwwroot/tree.aotl.cn/public"
ServerName SSL.tree.aoyintl.cn
ServerAlias tree.aoyintl.cn
#errorDocument 404 /404.html
ErrorLog "/www/wwwlogs/tree.aotl.cn-error_log"
CustomLog "/www/wwwlogs/tree.aotl.cn-access_log" combined
#下面是ssl配置
#SSL
SSLEngine On
SSLCertificateFile /www/server/panel/vhost/cert/tree.aoyintl.cn/fullchain.pem
SSLCertificateKeyFile /www/server/panel/vhost/cert/tree.aoyintl.cn/privkey.pem
SSLCipherSuite EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5
SSLProtocol All -SSLv2 -SSLv3 -TLSv1
SSLHonorCipherOrder On
#下面主要是webscoket配置
SSLProxyEngine on
ProxyRequests Off
ProxyPass /wss ws://121.89.223.120:7272
ProxyPassReverse /wss ws://tree.aotl.cn
#PHP
<FilesMatch \.php$>
SetHandler "proxy:unix:/tmp/php-cgi-73.sock|fcgi://localhost"
</FilesMatch>
#DENY FILES
<Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
Order allow,deny
Deny from all
</Files>
#PATH
<Directory "/www/wwwroot/tree.aoyintl.cn/public">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
</Directory>
</VirtualHost>
最主要的是(前提是配置好https(SSL))
#下面主要是webscoket配置
SSLProxyEngine on
ProxyRequests Off
ProxyPass /wss ws://121.89.223.120:7272
ProxyPassReverse /wss ws://tree.aotl.cn
测试链接
<script type="text/javascript">
// 证书是会检查域名的,请使用域名连接
ws = new WebSocket("wss://tree.aotl.cn/wss");
ws.onopen = function() {
alert("连接成功");
ws.send('tom');
alert("给服务端发送一个字符串:tom");
};
ws.onmessage = function(e) {
alert("收到服务端的消息:" + e.data);
};
</script>
|