Preface
For certain reasons, some of the things we say are not suited to mainstream chat apps — at least, I believe certain words may be flagged as risky by the system, and you could face muting, account freezes or bans, or even physical trouble. Self-hosting a private chat room helps you stay away from these troubles when you need it.
There is no shortage of chat room apps on the internet, but the advanced ones are closed-source and the simple ones are too plain for someone as looks-driven as me. After trying many, I settled on the Fiora chat app — because it's kind of cute and a bit Q.
Since I don't understand all kinds of programming and can't read code, I could only deploy it the beginner way, with aaPanel (宝塔). I found many tutorials about building Fiora with aaPanel online, skimmed various experts' articles and asked around — time to write a blog post to record it, so I can copy-paste next time I need it.
Fiora
The Fiora chat room is an open-source web chat room developed solo by 碎碎酱, based on Node.js and React, communicating via socket.io over WebSocket, with Service Worker and PWA support. It's feature-rich yet easy to get started with — a great reference project for learning Node.js, a blessing for Node.js beginners. (That sentence was sponsored; 碎碎酱, if you see this, pay up.)
Project: https://github.com/yinxin630/fiora
Demo sites:
Installing Fiora with aaPanel
- Install aaPanel yourself.
- In the app store, install the three apps: PM2 Manager, MongoDB, Redis.
- If you have an external firewall, open port 9200 in advance; open port 9200 in aaPanel too.
- Connect to the server via SSH.
First test the environment; if something is missing, exit and reconnect SSH:
node -v
npm -v
Pull the source code into /opt (install git first with yum -y install git if you don't have it):
git clone https://github.com/yinxin630/fiora.git -b master /opt/fiora
Enter the folder:
cd /opt/fiora
Install dependencies — you can't use npm here, you need yarn:
npm i -g yarn
yarn
Build and move the artifacts:
npm run build:client && npm run move-dist
Start it:
npm start
Register a user: open http://your-server-ip:9200 and register the first user: admin
Next, configure the administrator and auto-start on boot — first use Ctrl+C to stop the running process.
Create a symlink for node first, otherwise the later start will fail:
ln -sf $(which node) /usr/bin/node
Get the user's userid, e.g. for admin:
yarn script getUserId admin
Set the administrator — replace the content below with the userid you just got:
export Administrator=内容 Port=9200
Copy the following commands into your SSH client and run them together:
cat > /etc/systemd/system/fiora.service <<EOF
[Unit]
Description=fiora
After=network.target
Wants=network.target
[Service]
Type=simple
PIDFile=/var/run/fiora.pid
ExecStart=$(command -v npm) start
WorkingDirectory=/opt/fiora
Environment=NODE_ENV=production Administrator=$Administrator Port=$Port
User=root
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
EOF
Set the service to start on boot:
systemctl start fiora
Enable the service at boot:
systemctl enable fiora
Restart once more for the administrator privileges to take effect. Below is other reference content — modifying Fiora usually requires a rebuild to take effect.
Disable the service at boot (not needed, recorded for reference):
systemctl disable fiora
Rebuild (not needed, recorded for reference):
npm script build:client
Update (not needed, recorded for reference):
Pull the code:
git pull
Rebuild:
yarn build:client
Domain reverse proxy
If you want a certificate, close the domain reverse proxy while applying for / renewing the SSL.
- In the aaPanel panel, click Website on the left, add a site, then click the domain you added.
- Website → domain → Settings → Reverse proxy → Add reverse proxy
- Target URL http://127.0.0.1:9200
Open your domain and you can see Fiora running. For other settings, please refer to the official documentation.
Some fixes
1. New users can't register when behind a CDN
Go to opt/fiora/server/routes/user.ts and comment out lines 85–86:
// const hasRegisteredWithin24Hours = await Redis.has(getNewRegisteredUserIpKey(ctx.socket.ip));
// assert(!hasRegisteredWithin24Hours, '系统错误');
2. Cache issue — after modification, ip:9200 works but the domain still serves old files
Pause the domain's reverse proxy.
Turn off "Enable cache" in the reverse proxy settings.
Delete expires 12h; from the reverse proxy config file.
Empty the folder /www/server/nginx/proxy_cache_dir/
Empty the folder /www/server/nginx/proxy_temp_dir/
If you use a CDN, clear the CDN cache too.
Re-enable the domain's reverse proxy.
Hard-refresh / clear the browser cache / try another browser.
DIY (restart required for changes to take effect)
logo:
/opt/fiora/public/favicon-96.png
/opt/fiora/public/favicon-192.png
/opt/fiora/public/favicon-512.png
(The public directory is a build artifact — it gets overwritten on rebuild.)
index.html:
/opt/fiora/client/templates/index.html
/opt/fiora/public/index.html
Sidebar:
/opt/fiora/client/modules/Sidebar/
Security
https://github.com/yinxin630/fiora/blob/master/doc/INSTALL.ZH.md
As mentioned in the project documentation, create a .env file in the fiora root directory with the following content:
JwtSecret=*****
Replace the asterisks with random characters, save and restart the server.
Quantum Responses (0)