1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-11 07:10:39 +02:00

feat: add plausible analytics for blog

This commit is contained in:
oddlama 2024-09-18 16:48:48 +02:00
parent 3383fd9a14
commit c30ec709a7
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
16 changed files with 277 additions and 91 deletions

33
hosts/sentinel/blog.nix Normal file
View file

@ -0,0 +1,33 @@
{
globals,
pkgs,
...
}: {
services.nginx.virtualHosts.${globals.domains.me} = {
forceSSL = true;
useACMEWildcardHost = true;
locations."/".root = pkgs.runCommand "index.html" {} ''
mkdir -p $out
cat > $out/index.html <<EOF
<html>
<head>
<script defer data-api="/api/event" data-domain="oddlama.org" src="/js/script.js"></script>
</head>
<body>Not empty soon TM. Until then please go here: <a href="https://github.com/oddlama">oddlama</a></body>
</html>
EOF
'';
# Don't use the proxyPass option because we don't want the recommended proxy headers
locations."= /js/script.js".extraConfig = ''
proxy_pass https://${globals.services.plausible.domain}/js/script.js;
proxy_set_header Host ${globals.services.plausible.domain};
proxy_ssl_server_name on;
'';
locations."= /api/event".extraConfig = ''
proxy_pass https://${globals.services.plausible.domain}/api/event;
proxy_http_version 1.1;
proxy_set_header Host ${globals.services.plausible.domain};
proxy_ssl_server_name on;
'';
};
}