简体   繁体   English

带有Apache Server SSL的php中的Websocket

[英]Websocket in php with Apache Server SSL

I'm searching to configure websocket in Apache web server running in php, using Devristo phpws library to run websocket worker. 我正在使用Devristo phpws库运行websocket worker,以在运行php的Apache Web服务器中配置websocket。

When I run php file in the server it gives me this string: 当我在服务器上运行php文件时,它给了我这个字符串:

Resource id #442015-12-22T16:41:16+00:00 NOTICE (5): phpws listening on ssl://172.31.29.79:12345

In front-end, build on AngularJS, I tried to established connection with: 在前端,基于AngularJS,我尝试与以下对象建立连接:

var dataStream = $websocket('wss://subdomain.domain.com');

Google Chrome browser's console gives me this error: Google Chrome浏览器的控制台给我这个错误:

WebSocket connection to 'wss://subdomain.domain.com/' failed: Error during WebSocket handshake: Unexpected response code: 200

I've an EC2 AWS instance where I've hosted my source code and I've configured AWS Route 53 with a record set that point to the public IP of the instance through a subdomain. 我有一个EC2 AWS实例,在其中托管了源代码,并为AWS Route 53配置了一个记录集,该记录集通过子域指向实例的公共IP。

I don't know how configure a correctly reverse proxy to allow communication. 我不知道如何配置正确的反向代理以允许通信。

I tried to set Apache server with a Reverse Proxy, but I think I didn't configure it in the right way. 我尝试使用反向代理设置Apache服务器,但是我认为我没有以正确的方式配置它。

This is the configuration. 这是配置。 I've created a file in site-avaible calls websocket-ssl.conf and linked in site-enabled with this configuration: 我已经在网站可用的调用websocket-ssl.conf中创建了一个文件,并使用以下配置在启用网站的链接中进行了链接:

<VirtualHost *:80>
 ServerName subdomain.domain.com

 ProxyPass / ssl://172.31.29.79:12345/
 ProxyPassReverse / ssl://172.31.29.79:12345/
</VirtualHost>

Someone can help me in this? 有人可以帮我吗? If you want others information ask me :) 如果您需要其他信息,请问我:)

Thank you very much 非常感谢你

I solved with this configuration. 我用这种配置解决了。

  • set a record CNAME calls subdomain.domain.com in AWS Route 53 that point to my ELB dns name; 设置记录CNAME在AWS Route 53中调用subdomain.domain.com指向我的ELB dns名称;
  • open port 12345 in ELB listeners; 在ELB侦听器中打开端口12345;
  • in front-end I established connection with: 在前端,我与以下对象建立了联系:

    var dataStream = $websocket('wss://subdomain.domain.com:12345'); var dataStream = $ websocket('wss://subdomain.domain.com:12345');

That's all 就这样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM