working node server
This commit is contained in:
1047
UI/_/code/quill.js
1047
UI/_/code/quill.js
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 |
@@ -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>
|
||||
12
http.js
Normal file
12
http.js
Normal 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");
|
||||
});
|
||||
14
index.js
14
index.js
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user