working node server

This commit is contained in:
metacryst
2025-12-20 14:39:14 -06:00
parent ee841efabd
commit c6fc9c90c6
8 changed files with 22 additions and 1071 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

View File

@@ -1,13 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Admin</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="/_/icons/shield.png">
<link rel="stylesheet" href="/_/code/shared.css">
<script src="/_/code/quill.js"></script>
<script type="module" src="75820185/index.js"></script>
</head>
<body>
</body>
</html>

View File

12
http.js Normal file
View File

@@ -0,0 +1,12 @@
const http = require("http");
http.createServer((req, res) => {
const host = req.headers.host || "";
console.log("working")
res.writeHead(301, {
"Location": `https://${host}${req.url}`
});
res.end();
}).listen(2000, () => {
console.log("🔁 Redirect server running on port 2000");
});

View File

@@ -4,6 +4,7 @@ const http = require("http");
const https = require("https");
const tls = require("tls");
const httpProxy = require("http-proxy");
const { WebSocketServer } = require('ws')
const path = require("path");
// ---------------------------
@@ -80,13 +81,10 @@ function serveProxy(req, res, port) {
proxy.on("error", (err, req, res) => {
console.error("Proxy error:", err.message);
if (res.headersSent) {
res.end();
return;
}
res.writeHead(502, { "Content-Type": "text/plain" });
res.end("⚠️ target is unavailable. Please try again later.");
try {
res.statusCode = 502;
res.end("Bad Gateway");
} catch {}
});
proxy.on("proxyReq", (proxyReq, req, res) => {
@@ -135,7 +133,7 @@ function getPortForHost(host) {
case "admin.sun.museum":
return 8080
default:
default:
return null
}
}

View File

@@ -1,8 +1,9 @@
{
"scripts": {
"start": "node index.js"
},
"start": "node index.js"
},
"dependencies": {
"http-proxy": "^1.18.1"
"http-proxy": "^1.18.1",
"ws": "^8.18.3"
}
}