Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
testing new version
Browse files Browse the repository at this point in the history
  • Loading branch information
MyBooty165 authored Mar 19, 2024
1 parent 8594788 commit 632cd2f
Showing 1 changed file with 14 additions and 52 deletions.
66 changes: 14 additions & 52 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,20 @@
const http = require('http');
const httpProxy = require('http-proxy');
const express = require('express');
const path = require('path');
const cluster = require('cluster');
const numCPUs = require('os').cpus().length;
const { createProxyMiddleware } = require('http-proxy-middleware');

if (cluster.isMaster) {
console.log(`Slave ${process.pid} is running`);
const app = express();

for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}
const nggUrl = 'https://educationbluesky.com';

cluster.on('exit', (worker, code, signal) => {
console.log(`Slave ${worker.process.pid} died`);
cluster.fork();
});
} else {
const app = express();
const proxy = createProxyMiddleware({
target: nggUrl,
changeOrigin: true,
secure: true,
logLevel: 'debug',
});

const nggurl = 'https://mathsspot.com';
app.use('/', proxy);

const proxy = httpProxy.createProxyServer({
target: nggurl,
changeOrigin: true,
});

app.use('/', (req, res) => {
console.log(`Incoming Requests: ${req.url}`);
proxy.web(req, res);
});

app.use((req, res, next) => {
res.setHeader('Content-Security-Policy', 'default-src "self"; style-src "self"');
res.setHeader('X-Content-Type-Options', 'nosniff');
res.setHeader('X-Frame-Options', 'DENY');
res.setHeader('X-XSS-Protection', '1; mode=block');
res.setHeader('Content-Type', 'text/html');

next();
});

const server = http.createServer(app);

const PORT = 8080;
server.listen(PORT, () => {
console.log(`CybriaGG Slave ${process.pid} has been successfully run! On Port ${PORT}`);
});

process.on('unhandledRejection', (reason, promise) => {
console.error(`Slave ${process.pid} detected unhandled rejections:`, promise, 'reason:', reason);
});

process.on('uncaughtException', (err) => {
console.error(`Slave ${process.pid} uncaught exception:`, err);
});
}
const port = process.env.PORT || 8080;
app.listen(port, () => {
console.log(`CybriaGG is running on port ${port}`);
});

0 comments on commit 632cd2f

Please sign in to comment.