Nginx configration for websockets ⚙️
If you using Cloudflare:
1. Go to the
Network section.
2. Enable
Websockets option.
I also recommend that you read
this article in order to understand which ports are available to you.
Config changes:
1. Open main nginx config (usually path is
/etc/nginx/nginx.conf
)
2. Paste the following code into the
http {
section
NGINX:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
3. Open your domain configuration file.
4. Paste the following code inside the
location / {
section
NGINX:
location /chat.io/ {
proxy_pass http://127.0.0.1:2053;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
5. Restart nginx with
service nginx restart
command.
Running websockets server 🧦
Preconfiguration
1. Go to chat options.
2. Change "
Port" value to
2053.
3. Change "
Type of client-server communication" value to
(WebSocket) Proxied address. In the field that appears, write
/chat.io
.
Launch
1. Open SSH console on your server.
2. Go to the forum directory with
cd
command.
3. Start chat server with
php chat_cli start -d
command.
Stop
To stop the chat server, use the
php chat_cli stop
command.
Restart
To stop the chat server, use the
php chat_cli restart
command.
Port changing
When you change the port in the options, you need to restart the chat server.