Compare commits
No commits in common. "4432e3c4d0b2a1236d379eaa5e41884bc2038672" and "9873502b0850eff1cead090546031acdc7c3e390" have entirely different histories.
4432e3c4d0
...
9873502b08
12 changed files with 9 additions and 2510 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +0,0 @@
|
||||||
node_modules
|
|
5
.idea/.gitignore
vendored
5
.idea/.gitignore
vendored
|
@ -1,5 +0,0 @@
|
||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Editor-based HTTP Client requests
|
|
||||||
/httpRequests/
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="WEB_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="JavaScriptLibraryMappings">
|
|
||||||
<includedPredefinedLibrary name="Node.js Core" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,8 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/down-message.iml" filepath="$PROJECT_DIR$/.idea/down-message.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
|
@ -1,6 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
28
README.md
28
README.md
|
@ -3,31 +3,3 @@
|
||||||
[![Netlify Status](https://api.netlify.com/api/v1/badges/7821f152-5b28-4dec-9d98-035a18e8a57a/deploy-status)](https://app.netlify.com/sites/tdpeuter-down/deploys)
|
[![Netlify Status](https://api.netlify.com/api/v1/badges/7821f152-5b28-4dec-9d98-035a18e8a57a/deploy-status)](https://app.netlify.com/sites/tdpeuter-down/deploys)
|
||||||
|
|
||||||
Ultra simple website to tell people a service is down
|
Ultra simple website to tell people a service is down
|
||||||
|
|
||||||
## Starting the website
|
|
||||||
|
|
||||||
```shell
|
|
||||||
npm run start
|
|
||||||
```
|
|
||||||
|
|
||||||
## Setup networking
|
|
||||||
|
|
||||||
### Using [Cloudflare](https://dash.cloudflare.com)
|
|
||||||
|
|
||||||
If you want to use Cloudflare to handle redirection to the website, you can use [Page Rules](https://developers.cloudflare.com/support/page-rules/).
|
|
||||||
|
|
||||||
First, make sure the DNS records for the (sub-) domains you want to redirect are [being proxied through Cloudflare](https://developers.cloudflare.com/dns/manage-dns-records/reference/proxied-dns-records). Then, head over to [Redirect Rules](https://developers.cloudflare.com/rules/url-forwarding/) (Page Rules are harder to configure, and it seems like [Cloudflare itself is more keen of Redirect Rules too](https://developers.cloudflare.com/support/page-rules/recommended-page-rules-to-consider/)).
|
|
||||||
|
|
||||||
Create a Single Redirect rule that looks similar to:
|
|
||||||
|
|
||||||
```
|
|
||||||
# When incoming requests match...
|
|
||||||
(http.host in {"example.com" "another.example.com"})
|
|
||||||
|
|
||||||
# Then URL redirect
|
|
||||||
Dynamic
|
|
||||||
concat("https://your.host.tdl/?destination=", http.request.full_uri)
|
|
||||||
302
|
|
||||||
```
|
|
||||||
|
|
||||||
Enable the rule and everything should be set!
|
|
59
flake.lock
59
flake.lock
|
@ -1,59 +0,0 @@
|
||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"flake-utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1689068808,
|
|
||||||
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1691003216,
|
|
||||||
"narHash": "sha256-Qq/MPkhS12Bl0X060pPvX3v9ac3f2rRQfHjjozPh/Qs=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "4a56ce9727a0c5478a836a0d8a8f641c5b9a3d5f",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"id": "nixpkgs",
|
|
||||||
"type": "indirect"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
28
flake.nix
28
flake.nix
|
@ -1,28 +0,0 @@
|
||||||
{
|
|
||||||
description = "down-message";
|
|
||||||
|
|
||||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }:
|
|
||||||
flake-utils.lib.eachDefaultSystem
|
|
||||||
(system:
|
|
||||||
let
|
|
||||||
pkgs = import nixpkgs {
|
|
||||||
inherit system;
|
|
||||||
config.allowUnfree = true;
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
devShells.default = pkgs.mkShell {
|
|
||||||
packages = with pkgs; [
|
|
||||||
jetbrains.webstorm
|
|
||||||
nodejs
|
|
||||||
nodePackages.live-server
|
|
||||||
];
|
|
||||||
|
|
||||||
shellHook = ''
|
|
||||||
webstorm . && exit
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
2332
package-lock.json
generated
2332
package-lock.json
generated
File diff suppressed because it is too large
Load diff
19
package.json
19
package.json
|
@ -1,19 +0,0 @@
|
||||||
{
|
|
||||||
"name": "down-message",
|
|
||||||
"version": "1.1.0",
|
|
||||||
"description": "Ultra simple website to tell people a service is down",
|
|
||||||
"main": "index.html",
|
|
||||||
"scripts": {
|
|
||||||
"start": "live-server --port=3000 .",
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://git.depeuter.dev/tdpeuter/down-message.git"
|
|
||||||
},
|
|
||||||
"author": "Tibo De Peuter <tibo@depeuter.dev>",
|
|
||||||
"license": "GPL-3.0-only",
|
|
||||||
"devDependencies": {
|
|
||||||
"live-server": "^1.2.2"
|
|
||||||
}
|
|
||||||
}
|
|
15
script.js
15
script.js
|
@ -1,18 +1,15 @@
|
||||||
async function websiteUp(url) {
|
async function websiteUp(url) {
|
||||||
// TODO Fix CORS
|
// TODO Fix CORS
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, { method: 'options' });
|
const response = await fetch(url, { method: 'head' });
|
||||||
return response.ok;
|
console.log(response);
|
||||||
|
return false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`An error occurred while checking the URL '${url}': ${error.message}`);
|
console.error(`An error occurred while checking the URL '${url}': ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function check(destination, container, dot, message, button) {
|
async function check(destination, container, dot, message, button) {
|
||||||
dot.className = 'dot orange';
|
|
||||||
message.textContent = 'Checking availability...';
|
|
||||||
button.style.visibility = 'hidden';
|
|
||||||
|
|
||||||
const destinationUp = await websiteUp(destination);
|
const destinationUp = await websiteUp(destination);
|
||||||
|
|
||||||
if (destinationUp) {
|
if (destinationUp) {
|
||||||
|
@ -37,8 +34,14 @@ async function check(destination, container, dot, message, button) {
|
||||||
|
|
||||||
function createCheckButton(destination) {
|
function createCheckButton(destination) {
|
||||||
const dot = document.createElement('span');
|
const dot = document.createElement('span');
|
||||||
|
dot.className = 'dot orange';
|
||||||
|
dot.id = 'checkDot';
|
||||||
|
|
||||||
const message = document.createElement('span');
|
const message = document.createElement('span');
|
||||||
|
message.textContent = 'Checking availability...';
|
||||||
|
|
||||||
const button = document.createElement('button');
|
const button = document.createElement('button');
|
||||||
|
button.style.visibility = 'hidden';
|
||||||
|
|
||||||
const container = document.getElementById('checkContainer');
|
const container = document.getElementById('checkContainer');
|
||||||
container.appendChild(dot);
|
container.appendChild(dot);
|
||||||
|
|
Loading…
Reference in a new issue