diff --git a/README.md b/README.md index 6fc55c3..8664203 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,8 @@ It should also run under the newer/faster [Bun Runtime](https://bun.sh/) If it comes up successfully, go to a browser and put in a HTTPS request to your domain name. If you get a dashboard, you have done everything correctly. +The install will redirect http to https, if you don't want the redirect, see the end of [index.js](index.js) + I have included a systemd service file in the util subdirectory which can be copied to /lib/systemd/system ``` sudo cp util/dsgwdashboard.service /lib/systemd/system diff --git a/index.js b/index.js index ef92bb4..b9e3438 100644 --- a/index.js +++ b/index.js @@ -135,3 +135,12 @@ const tailheaders = new Tail(headers, {startPos : 'end'}, line => { }); tailheaders.start(); +// Comment out the following lines if you don't want to redirect http to https +var http = require("http"); + +http + .createServer(function (req, res) { + res.writeHead(301, { Location: "https:"+host }); + res.end(); + }) + .listen(80); diff --git a/package-lock.json b/package-lock.json index b914257..9f5b288 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "configparser": "^0.3.10", "express": "^4.18.2", "express-ws": "^5.0.2", + "http": "^0.0.1-security", "ini": "^4.1.1", "jquery": "^3.7.1", "line-reader": "^0.4.0", @@ -479,6 +480,11 @@ "node": ">= 0.4" } }, + "node_modules/http": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/http/-/http-0.0.1-security.tgz", + "integrity": "sha512-RnDvP10Ty9FxqOtPZuxtebw1j4L/WiqNMDtuc1YMH1XQm5TgDRaR1G9u8upL6KD1bXHSp9eSXo/ED+8Q7FAr+g==" + }, "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", diff --git a/package.json b/package.json index 769c994..494dee9 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "configparser": "^0.3.10", "express": "^4.18.2", "express-ws": "^5.0.2", + "http": "^0.0.1-security", "ini": "^4.1.1", "jquery": "^3.7.1", "line-reader": "^0.4.0",