working pre-update
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import "newrelic"
|
||||
|
||||
import http from "http";
|
||||
import express,{Router} from "express";
|
||||
import useragent from "express-useragent";
|
||||
@@ -14,7 +12,6 @@ import { readFileSync, appendFile } from "fs";
|
||||
import { format } from "util";
|
||||
import { setup as SETUP_ROUTES} from "./routes/setup_all_routes.js"
|
||||
import { verify as verifyHCaptcha_int } from "hcaptcha"
|
||||
import hsts from "hsts"
|
||||
|
||||
import { ensureExists } from "./extra_modules/ensureExists.js"
|
||||
|
||||
@@ -263,24 +260,14 @@ app.use(fileUpload({
|
||||
}
|
||||
}));
|
||||
|
||||
const hstsMiddleware = hsts({
|
||||
maxAge: 31536000,
|
||||
includeSubDomains: true,
|
||||
preload: true
|
||||
})
|
||||
|
||||
app.use((req, res, next) => {
|
||||
app.use((_req, res, next) => {
|
||||
res.set("x-powered-by", "ipost");
|
||||
res.set("X-Frame-Options","DENY");
|
||||
res.set("X-XSS-Protection","1; mode=block");
|
||||
res.set("X-Content-Type-Options","nosniff");
|
||||
res.set("Referrer-Policy","no-referrer");
|
||||
|
||||
if (req.secure) {
|
||||
hstsMiddleware(req, res, next)
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
next()
|
||||
})
|
||||
|
||||
app.use(bodyParser.default.json({ limit: "100mb" }));
|
||||
@@ -312,18 +299,6 @@ app.use(function (_req, res, next) {
|
||||
next();
|
||||
});
|
||||
|
||||
//auto redirect to https
|
||||
app.use((req, res, next) => {
|
||||
if (req.secure) {
|
||||
//already secure
|
||||
next();
|
||||
}
|
||||
else {
|
||||
//redirect to https
|
||||
res.redirect('https://' + req.headers.host + req.url);
|
||||
}
|
||||
});
|
||||
|
||||
app.use("/*", function (req, res, next) {
|
||||
for (let i = 0; i < blocked_headers.length; i++) {
|
||||
if (req.header(blocked_headers[i]) !== undefined) {
|
||||
@@ -394,21 +369,9 @@ const httpServer = http.createServer(app);
|
||||
httpServer.listen(config["ports"]["http"], function () {
|
||||
console.log(5, "HTTP Server is listening");
|
||||
});
|
||||
const privateKey = readFileSync(config["ssl"]["privateKey"]).toString();
|
||||
const certificate = readFileSync(config["ssl"]["certificate"]).toString();
|
||||
const credentials = { key: privateKey, cert: certificate };
|
||||
var httpsServer;
|
||||
|
||||
import spdy from "spdy"
|
||||
|
||||
httpsServer = spdy.createServer(credentials,app)
|
||||
//httpsServer = https.createServer(credentials, app);
|
||||
httpsServer.listen(config["ports"]["https"], function () {
|
||||
console.log(5, "HTTPS Server is listening");
|
||||
});
|
||||
|
||||
wss = new WebSocket({
|
||||
server: httpsServer,
|
||||
server: httpServer,
|
||||
perMessageDeflate: {
|
||||
zlibDeflateOptions: {
|
||||
chunkSize: 1024,
|
||||
|
||||
Reference in New Issue
Block a user