资源:
Ratchet - WebSockets for PHP (http://socketo.me)
Web Socket Chat - Online chat based on web sockets and ratchet php (https://github.com/joni-jones/yii2-wschat)
使用Nginx反向代理Websocket(ws/wss):[编辑]
编辑网站对应的vhost配置文件,加入如下配置
upstream backend {
server 127.0.0.1:8090;
}
server {
...
location /chatwss/ {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Websocket应用的Server端使用 ws://ip:port 或 ws://example.com/chatwss/ 即可与Client建立链接。
注:ws://example.com/chatwss/ 中的chatwss 取决于Nginx配置文件,如配置文件的 location /chatwss/有斜杠,Server端使用时也需加上。
参考资料:http://www.cnblogs.com/mafly/p/websocket.html