Diogo Cordeiro 96c4e57ac0 Add gs-wsRealtime by Chimo | 5 years ago | |
---|---|---|
.. | ||
daemon | 5 years ago | |
js | 5 years ago | |
src | 5 years ago | |
.gitignore | 5 years ago | |
LICENSE | 5 years ago | |
README.md | 5 years ago | |
WebSocketsPlugin.php | 5 years ago |
Plugin to do "real time" updates using Websockets
libevent is also recommended (see the Ratchet documentation about "deployment")
$GNUSOCIAL_ROOT/config.php
(replace $SERVER with your hostname):$config['websockets']['webserver'] = '$SERVER'; // Your SN/GS hostname
$config['websockets']['webport'] = '8080'; // webport to use over HTTP
$config['websockets']['sslport'] = '8081'; // webport to use over HTTPS
$config['websockets']['path'] = ''; // webpath where the websocket endpoint is
$config['websockets']['controlserver'] = '127.0.0.1'; // Server where the daemon is running
$config['websockets']['controlport'] = '5555'; // Port on which the daemon is running
addPlugin('WebSockets');
With the configuration values above, the browser will try to open a websocket connection at:
If you don't want do open ports, you can set 'webport' to '80' and 'sslport' to '443' and 'path' wherever you set your webserver to proxy_pass requests to the websocket backend:
$config['websockets']['webserver'] = '$SERVER'; // Your SN/GS hostname
$config['websockets']['webport'] = '80'; // webport to use over HTTP
$config['websockets']['sslport'] = '443'; // webport to use over HTTPS
$config['websockets']['path'] = '/_ws'; // webpath where the websocket endpoint is
$config['websockets']['controlserver'] = '127.0.0.1'; // Server where the daemon is running
$config['websockets']['controlport'] = '5555'; // Port on which the daemon is running
addPlugin('WebSockets');
In that case the browser will open a websocket connection at:
Ratchet doesn't support SSL. One work-around is to use nginx to proxy those requests.
Something based on the following nginx config might work.
Replace $SERVER with your GS hostname.
Make sure to point to your SSL cert/key.
upstream websocket {
server $SERVER:8080;
}
server {
server_name $SERVER;
listen 8081 ssl;
ssl_certificate /PATH/TO/CERT.crt;
ssl_certificate_key /PATH/TO/CERTKEY.key;
access_log /var/log/wss-access.log;
error_log /var/log/wss-error.log;
location / {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
}
}
Another work-around is to use stunnel. I haven't looked into this yet.