Add proxy entry for today's garfield comic
This commit is contained in:
parent
762b6c45cc
commit
3625092420
3 changed files with 72 additions and 1 deletions
|
@ -1,5 +1,10 @@
|
|||
{ self, ... }:
|
||||
{ modulesPath, lib, ... }:
|
||||
{
|
||||
pkgs,
|
||||
modulesPath,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
"${modulesPath}/profiles/qemu-guest.nix"
|
||||
|
@ -118,6 +123,22 @@
|
|||
enable = true;
|
||||
permitCertUid = "caddy";
|
||||
};
|
||||
|
||||
caddy = {
|
||||
virtualHosts = {
|
||||
"garfield.datarift.nl" =
|
||||
let
|
||||
webRoot = pkgs.writeTextDir "index.html" (builtins.readFile ../proxy/index.html);
|
||||
in
|
||||
{
|
||||
extraConfig = ''
|
||||
root * ${webRoot}
|
||||
rewrite * /index.html
|
||||
file_server
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
security = {
|
||||
|
|
|
@ -104,6 +104,28 @@
|
|||
sudo.enable = false;
|
||||
};
|
||||
|
||||
services = {
|
||||
caddy = {
|
||||
virtualHosts = {
|
||||
"garfield.datarift.nl" =
|
||||
let
|
||||
webRoot = pkgs.writeTextDir "index.html" (builtins.readFile ./index.html);
|
||||
in
|
||||
{
|
||||
extraConfig = ''
|
||||
root * ${webRoot}
|
||||
rewrite * /index.html
|
||||
file_server
|
||||
tls {
|
||||
dns cloudflare {env.CF_API_TOKEN}
|
||||
resolvers 1.1.1.1
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
sops.defaultSopsFile = ./secrets.yaml;
|
||||
sops.secrets = {
|
||||
caddy-env = { };
|
||||
|
|
28
machines/proxy/index.html
Normal file
28
machines/proxy/index.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Today's Garfield</title>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const date = new Date();
|
||||
|
||||
const year = date.getFullYear();
|
||||
let month = date.getMonth() + 1;
|
||||
let day = date.getDate();
|
||||
|
||||
if (month < 10) {
|
||||
month = "0" + month;
|
||||
}
|
||||
|
||||
if (day < 10) {
|
||||
day = "0" + day;
|
||||
}
|
||||
const url = `https://www.gocomics.com/garfield/${year}/${month}/${day}/`;
|
||||
console.log(`Redirecting to ${url}`);
|
||||
location.href = url;
|
||||
});
|
||||
</script>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
Loading…
Reference in a new issue