# Websocket server installation
If you have a VPS/VDS, you can set up your own web socket server with Soketi (opens new window).
If you don't have this option, you can use the Pusher API (opens new window).
# Install Soketi on a same server
# Prepare nginx configuration
- Open main nginx config (usually path is
/etc/nginx/nginx.conf
) - Paste the following code into the
http
section:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
- Open your domain configuration file.
- Paste the following code to the bottom and save it (opens new window):
server {
# Comment if using an ssl certificate.
listen 2096 http2;
listen [::]:2096 http2;
# Uncomment if using an ssl certificate.
# listen 2096 ssl http2;
# listen [::]:2096 ssl http2;
server_name your_domain.com;
server_tokens off;
root /path/to/your/forum;
index index.php;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
# Uncomment if using an ssl certificate.
# ssl on;
# ssl_certificate /path/to/your/certificate.pem;
# ssl_certificate_key /path/to/your/certificate.key;
charset utf-8;
location / {
proxy_pass http://127.0.0.1:6001;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
- Restart nginx:
service nginx restart
# Install and configure Soketi
Go to the forum directory:
cd /path/to/your/forum
Create a config for Soketi:
php cmd.php xf-websockets:create-soketi-config
Now you need to choose how you want to run the websocket server - directly on the server or in a docker container.
The docker container allows you to avoid conflicts with the environment settings and run the server even on OSes that are not compatible with Soketi (such as CentOS 7).
To run the server in a docker container, Docker (opens new window) must be installed on the server.
# Install Soketi directly on the server
bash websockets install-soketi
# Install Soketi image for Docker container
bash websockets pull-docker-image
Run a daemon after this. Choose one of the options below.
# Run a daemon using systemd
# Daemon to run Soketi directly on the server
bash websockets install-systemd-service your_domain.com
# Daemon to run Soketi in a docker container
bash websockets install-systemd-service your_domain.com --docker
Now you can check the status of the daemon with the command:
systemctl status soketi.your_domain.com
# Run a daemon using supervisor
# Service to run Soketi directly on the server
bash websockets install-supervisor-service your_domain.com
# Service to run Soketi in a docker container
bash websockets install-supervisor-service your_domain.com --docker
Now you can check the status of the daemon with the command:
supervisorctl status soketi.your_domain.com
# Install Soketi on a separate server
Prepare your nginx configuration as described in the nginx configuration manual.
Connect to the forum server.
Go to the forum directory:
cd /path/to/your/forum
Create a config for Soketi:
php cmd.php xf-websockets:create-soketi-config
Connect to the server where you want to run Soketi.
Upload the
websockets
file from the addon archive to the server.Go to the directory where you uploaded the file:
cd /path/to/your/websockets/file
Create
src
directory.mkdir src
Upload the
src/soketi.config.json
file from the forum root directory to thesrc
directory on the server.Run a daemon after this. Choose one of these options.
Open XenForo WebSockets options:
ACP > Setup > Options > [021] XenForo WebSockets
.Paste the server IP or domain with protocol into the
Pusher host
field. For example:https://your_domain.com
.
# Use Pusher API
- Create an account on Pusher (opens new window).
- Go to the Dashboard (opens new window) and click on the "Get started" button in the "Channels" section.
- Create a new app:
You can name it as you want.
Choose the cluster that is closest to your server.
The rest of the options don't matter. - Go to the "App Keys" tab.
- Open XenForo WebSockets options:
ACP > Setup > Options > [021] XenForo WebSockets
. - Paste the values from the "App Keys" tab into the corresponding fields.
- Save the options.