我看过这个教程,但不能让它工作
https://www.sanwebe.com/2013/05/chat-using-websocket-php-socket
已将三个文件复制到www目录的根目录中
的index.PHP
/jquery-3.1.1.js
/websocket/server.PHP
在index.PHP中,我更改了URI
var wsUri = "wss://domain.com/websocket/server.PHP";
http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
location /websocket/ {
proxy_pass https://domain.com:9000/websocket/server.PHP;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
}
http://nginx.org/en/docs/http/websocket.html
启动websocket服务器
PHP -q /var/www/websocket/server.PHP
聊天位于https://domain.com/chat.PHP并加载,但在聊天窗口中出现此错误发生错误 – 连接已关闭
还试图通过此工具连接,但得到此错误
http://www.websocket.org/echo.html
ERROR: undefined
DISCONNECTED
如果通过浏览器请求
wss://domain.com/websocket/server.PHP
ERR_DISALLOWED_URL_SCHEME