Compare commits
4 commits
9873502b08
...
4432e3c4d0
Author | SHA1 | Date | |
---|---|---|---|
4432e3c4d0 | |||
48641bdef1 | |||
69e78963d7 | |||
5368b1815f |
12 changed files with 2510 additions and 9 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
node_modules
|
5
.idea/.gitignore
vendored
Normal file
5
.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
12
.idea/down-message.iml
Normal file
12
.idea/down-message.iml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?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>
|
6
.idea/jsLibraryMappings.xml
Normal file
6
.idea/jsLibraryMappings.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="JavaScriptLibraryMappings">
|
||||||
|
<includedPredefinedLibrary name="Node.js Core" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?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>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?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,3 +3,31 @@
|
||||||
[![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
Normal file
59
flake.lock
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
{
|
||||||
|
"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
Normal file
28
flake.nix
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
{
|
||||||
|
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
Normal file
2332
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
19
package.json
Normal file
19
package.json
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"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,15 +1,18 @@
|
||||||
async function websiteUp(url) {
|
async function websiteUp(url) {
|
||||||
// TODO Fix CORS
|
// TODO Fix CORS
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url, { method: 'head' });
|
const response = await fetch(url, { method: 'options' });
|
||||||
console.log(response);
|
return response.ok;
|
||||||
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) {
|
||||||
|
@ -34,14 +37,8 @@ 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