This project consists of an interactive installation using WebSockets to communicate between a main display (LabirintosFinal), a wall display (labirintosWall), and a server (labirintosServer.js).
LabirintosFinal/: Main interactive displaylabirintosWall/: Wall display for accumulated textlabirintosServer.js: WebSocket serverpackage.json: Node.js project file
- Log in to your DigitalOcean account.
- Create a new Droplet with Ubuntu (latest LTS version).
- Choose the Basic plan with the cheapest option.
- Select a datacenter region close to your target audience.
- Choose SSH keys or password for authentication.
- Create the Droplet.
ssh root@your_droplet_ipsudo apt update && sudo apt upgrade -y
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt install gitgit clone https://your-repository-url.git
cd your-project-directory
npm installGenerate a self-signed certificate:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/selfsigned.key -out /etc/ssl/certs/selfsigned.crtWhen prompted, use your server's IP address for the "Common Name" field.
Update labirintosServer.js to use HTTPS and WSS:
const https = require('https');
const WebSocket = require('ws');
const fs = require('fs');
const path = require('path');
const options = {
cert: fs.readFileSync('/etc/ssl/certs/selfsigned.crt'),
key: fs.readFileSync('/etc/ssl/private/selfsigned.key')
};
const server = https.createServer(options, (req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
res.setHeader('Access-Control-Allow-Credentials', true);
res.end();
});
const wss = new WebSocket.Server({ server });
// ... rest of your server code ...
const port = process.env.PORT || 8080;
server.listen(port, () => {
console.log(`Secure WebSocket server is running on port ${port}`);
// ... rest of your server startup code ...
});sudo npm install pm2 -g
pm2 start labirintosServer.js
pm2 startup systemd
pm2 savesudo ufw allow OpenSSH
sudo ufw allow 8080/tcp
sudo ufw enableUpdate both LabirintosFinal/sketch.js and labirintosWall/sketch.js to use secure WebSocket:
socket = new WebSocket('wss://your_droplet_ip:8080');Replace your_droplet_ip with your DigitalOcean Droplet's IP address.
- Ensure the server is running on your DigitalOcean Droplet.
- Open
LabirintosFinal/index.htmlon the main display device. - Open
labirintosWall/index.htmlon the wall display device.
- If you encounter security warnings in the browser, you may need to manually accept the risk due to the self-signed certificate.
- For testing, you might need to lower your browser's security settings or use a tool like Postman that allows ignoring SSL certificate errors.
- To view server logs:
pm2 logs labirintosServer
- Replace the self-signed certificate with a trusted SSL certificate (e.g., Let's Encrypt) for better security and browser compatibility.
- Set up a domain name for your server for easier management and security.
The current setup uses a self-signed certificate, which is suitable for testing but not recommended for production. For a public-facing installation, consider using a domain name and obtaining a certificate from a trusted authority like Let's Encrypt.