Server Installation
If you have a VPS/VDS, you can set up your own websockets server with Soketi.
If you don't have this option, you can use the Pusher API or install Soketi on a remote server.
How to install Soketi on a forum server?
Prepare nginx configuration
- Open main nginx config (usually path is
/etc/nginx/nginx.conf) - Paste the following code into the
httpsection:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}- Open your domain configuration file.
- Paste the following code to the bottom and save it:
server {
# Comment if using an ssl certificate.
listen 2096;
listen [::]:2096;
# Uncomment if using an ssl certificate.
# listen 2096 ssl;
# listen [::]:2096 ssl;
# ssl_certificate /path/to/your/certificate.pem;
# ssl_certificate_key /path/to/your/certificate.key;
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";
http2 on;
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 restartSetup Soketi
Go to the forum directory:
cd /path/to/your/forumCreate a config for Soketi:
php cmd.php xf-websockets:create-soketi-configChoose how to run Soketi
INFO
You now need to decide how to run the WebSocket server: either directly on your server or within a Docker container. Running Soketi in a Docker container offers several advantages:
- Avoiding conflicts with your server's environment settings.
- Compatibility with operating systems that don’t natively support Soketi (e.g., CentOS 7).
If you choose the Docker option, ensure that Docker is installed on your server beforehand.
Install native Soketi
To install native Soketi on your server, run the following command:
bash websockets install-soketiInstall Soketi Docker Image
To use Soketi in a Docker container, pull the Docker image by running:
bash websockets pull-docker-imageTIP
Now you need to run a daemon to keep Soketi running in background. Use either systemd or supervisor to run a daemon.
Run a Daemon with systemd
Daemon to run native Soketi
To install a systemd service which runs Soketi directly installed on the server, run the following command:
bash websockets install-systemd-service your_domain.comDaemon to run Soketi in a Docker container
bash websockets install-systemd-service your_domain.com --dockerTIP
You can check the status of the daemon with the command:
systemctl status soketi.your_domain.comRun a Daemon using supervisor
Daemon to run native Soketi
bash websockets install-supervisor-service your_domain.comDaemon to run Soketi in a Docker container
bash websockets install-supervisor-service your_domain.com --dockerTIP
You can check the status of the daemon with the command:
supervisorctl status soketi.your_domain.comHow to install Soketi on a remote server?
Prepare nginx configuration
- Open main nginx config (usually path is
/etc/nginx/nginx.conf) - Paste the following code into the
httpsection:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}- Open your domain configuration file.
- Paste the following code to the bottom and save it:
server {
# Comment if using an ssl certificate.
listen 2096;
listen [::]:2096;
# Uncomment if using an ssl certificate.
# listen 2096 ssl;
# listen [::]:2096 ssl;
# ssl_certificate /path/to/your/certificate.pem;
# ssl_certificate_key /path/to/your/certificate.key;
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";
http2 on;
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 restartSetup Soketi
- 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
websocketsfile from the add-on archive to the server. - Go to the directory where you uploaded the file:
cd /path/to/your/websockets/file- Create
srcdirectory.
mkdir src- Upload the
src/soketi.config.jsonfile from the forum root directory to thesrcdirectory on the server. - Install native Soketi or Docker Image.
- Run a daemon.
- Open XenForo WebSockets options:
ACP > Setup > Options > [021] XenForo WebSockets. - Paste the server IP or domain into the
Pusher Hostfield (eg.ws.your_domain.com).
How to use the Pusher API?
- Create an account on pusher.com.
- Go to the Dashboard and click on the
Get startedbutton in theChannelssection. - 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.
