用nginx配置websocket服务器
系统环境
ubuntu14.04 Desktop x64
编译nginx
apt-get安装的nginx并不支持websocket,需要添加nginx-push-stream-module模块,所以我们要重新编译nginx。
编译参考模块给出的 参考地址
1 | git clone https://github.com/wandenberg/nginx-push-stream-module.git |
更多config配置,使用./config –help默认安装在/usr/local/nginx下
配置websocket
1 | # add the push_stream_shared_memory_size to your http context |
配置一个publisher,配置一个subscriber,以id区分每一个channel也可以直接nginx加载misc/nginx.conf
测试
推荐使用curl直接测试,也可以选择使用iocat测试,需要安装node.js以及npm
1 | npm install iocat -g |