Hi
I had the pm2 manager installed since I created the aaPanel and it's been working great for years but suddenly stopped working for no reason. I have been many days trying to fix it, by googling solutions but none of them worked. The last time it stopped working I did the trick of changing the Node on the "pm2 manager" and it worked well. But this time none of the node versions worked, it always shows (system), and I tested all of them. I also uninstalled, pm2 manager, node.js, npm, pm2, etc... and installed them again though it didn't work.
I also read from you on the forum that the "Website Node Project" works better but that solution didn't work for me, swell.
I updated the aaPanel to the latest version but still didnt fix the issue
Im just trying to run the script:
"app.js"
From this path:
/www/wwwroot/wss
The script is just a quick check for a domain, here is what it has inside:
const https = require("https");
const fs = require("fs");
const ws = require('ws');
const options = {
key: fs.readFileSync(
"/www/server/panel/vhost/cert/ws.mywebsitecom/privkey.pem"
),
cert: fs.readFileSync(
"/www/server/panel/vhost/cert/ws.mywebsitecom/fullchain.pem"
),
};
var approveddomains=["website1.net","localhost","mywebsitecom"]
function getDomainWithoutSubdomain(url){
const urlParts = new URL(url).hostname.split('.')
return urlParts
.slice(0)
.slice(-(urlParts.length === 4 ? 3 : 2))
.join('.')
};
const server = https.createServer(options);
const wss = new ws.WebSocketServer({ server });
wss.on("connection", function connection(ws,req) {
if (approveddomains.includes(getDomainWithoutSubdomain(req.headers.origin)))
{
console.log("ok");
ws.send("ok");
}
else
{
console.log("block");
ws.send("block");
}
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
});
server.listen(8443);