mirror of
https://github.com/RGBCube/ncc
synced 2025-07-27 18:17:44 +00:00
plausible: add to other services
This commit is contained in:
parent
e7cf9c7239
commit
f8c824dd0a
6 changed files with 31 additions and 10 deletions
|
@ -111,6 +111,10 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nginx.virtualHosts.${fqdn} = merge config.services.nginx.sslTemplate {
|
services.nginx.virtualHosts.${fqdn} = merge config.services.nginx.sslTemplate {
|
||||||
|
extraConfig = ''
|
||||||
|
${config.services.plausible.extraNginxConfigFor fqdn}
|
||||||
|
'';
|
||||||
|
|
||||||
locations."/".proxyPass = "http://[::1]:${toString port}";
|
locations."/".proxyPass = "http://[::1]:${toString port}";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,8 @@ in {
|
||||||
# Grafana sets `nosniff` while not setting the content type properly,
|
# Grafana sets `nosniff` while not setting the content type properly,
|
||||||
# so everything breaks with it. Unset the header.
|
# so everything breaks with it. Unset the header.
|
||||||
proxy_hide_header X-Content-Type-Options;
|
proxy_hide_header X-Content-Type-Options;
|
||||||
|
|
||||||
|
${config.services.plausible.extraNginxConfigFor fqdn}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
proxyPass = "http://[::1]:${toString port}";
|
proxyPass = "http://[::1]:${toString port}";
|
||||||
|
|
|
@ -111,6 +111,8 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nginx.virtualHosts.${fqdn} = merge config.services.nginx.sslTemplate {
|
services.nginx.virtualHosts.${fqdn} = merge config.services.nginx.sslTemplate {
|
||||||
extraConfig = config.services.nginx.headers;
|
extraConfig = ''
|
||||||
|
${config.services.nginx.headers}
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{ config, self, lib, ... }: let
|
{ config, self, lib, ... }: let
|
||||||
inherit (config.networking) domain;
|
inherit (config.networking) domain;
|
||||||
inherit (lib) enabled merge;
|
inherit (lib) enabled merge mkConst;
|
||||||
|
|
||||||
fqdn = "shekels.${domain}";
|
fqdn = "shekels.${domain}";
|
||||||
port = 8007;
|
port = 8007;
|
||||||
|
@ -10,14 +10,14 @@ in {
|
||||||
(self + /modules/postgresql.nix)
|
(self + /modules/postgresql.nix)
|
||||||
];
|
];
|
||||||
|
|
||||||
secrets.plausibleKey = {
|
config.secrets.plausibleKey = {
|
||||||
file = ./key.age;
|
file = ./key.age;
|
||||||
owner = "plausible";
|
owner = "plausible";
|
||||||
};
|
};
|
||||||
|
|
||||||
services.postgresql.ensure = [ "plausible" ];
|
config.services.postgresql.ensure = [ "plausible" ];
|
||||||
|
|
||||||
services.plausible = enabled {
|
config.services.plausible = enabled {
|
||||||
server = {
|
server = {
|
||||||
disableRegistration = true; # Setting it explicitly just in case.
|
disableRegistration = true; # Setting it explicitly just in case.
|
||||||
|
|
||||||
|
@ -30,7 +30,16 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nginx.virtualHosts.${fqdn} = merge config.services.nginx.sslTemplate {
|
options.services.plausible.extraNginxConfigFor = mkConst /* nginx */ (domain: ''
|
||||||
|
proxy_set_header Accept-Encoding ""; # Substitution won't work if it is compressed.
|
||||||
|
sub_filter "</head>" '<script defer data-domain="${domain}" src="https://${fqdn}/js/script.js"></script></head>';
|
||||||
|
sub_filter_last_modified on;
|
||||||
|
sub_filter_once on;
|
||||||
|
'');
|
||||||
|
|
||||||
|
config.services.nginx.virtualHosts.${fqdn} = merge config.services.nginx.sslTemplate {
|
||||||
|
extraConfig = config.services.plausible.extraNginxConfigFor fqdn;
|
||||||
|
|
||||||
locations."/" = {
|
locations."/" = {
|
||||||
proxyPass = "http://[::1]:${toString port}";
|
proxyPass = "http://[::1]:${toString port}";
|
||||||
proxyWebsockets = true;
|
proxyWebsockets = true;
|
||||||
|
|
|
@ -52,6 +52,7 @@ in {
|
||||||
https "max-age=31536000; includeSubdomains; preload";
|
https "max-age=31536000; includeSubdomains; preload";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# FIXME: These two aren't working.
|
||||||
map $http_origin $allow_origin {
|
map $http_origin $allow_origin {
|
||||||
~^https://.+\.${domain}$ $http_origin;
|
~^https://.+\.${domain}$ $http_origin;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
inherit (config.networking) domain;
|
inherit (config.networking) domain;
|
||||||
inherit (lib) enabled merge;
|
inherit (lib) enabled merge;
|
||||||
|
|
||||||
|
fqdn = domain;
|
||||||
root = "/var/www/site";
|
root = "/var/www/site";
|
||||||
in {
|
in {
|
||||||
imports = [(self + /modules/nginx.nix)];
|
imports = [(self + /modules/nginx.nix)];
|
||||||
|
@ -16,7 +17,7 @@ in {
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
virtualHosts.${domain} = merge config.services.nginx.sslTemplate {
|
virtualHosts.${fqdn} = merge config.services.nginx.sslTemplate {
|
||||||
inherit root;
|
inherit root;
|
||||||
|
|
||||||
locations."/".tryFiles = "$uri $uri.html $uri/index.html =404";
|
locations."/".tryFiles = "$uri $uri.html $uri/index.html =404";
|
||||||
|
@ -29,6 +30,8 @@ in {
|
||||||
|
|
||||||
extraConfig = /* nginx */ ''
|
extraConfig = /* nginx */ ''
|
||||||
error_page 404 /404.html;
|
error_page 404 /404.html;
|
||||||
|
|
||||||
|
${config.services.plausible.extraNginxConfigFor fqdn}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
locations."/404".extraConfig = /* nginx */ ''
|
locations."/404".extraConfig = /* nginx */ ''
|
||||||
|
@ -36,12 +39,12 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
virtualHosts."www.${domain}" = merge config.services.nginx.sslTemplate {
|
virtualHosts."www.${fqdn}" = merge config.services.nginx.sslTemplate {
|
||||||
locations."/".return = "301 https://${domain}$request_uri";
|
locations."/".return = "301 https://${fqdn}$request_uri";
|
||||||
};
|
};
|
||||||
|
|
||||||
virtualHosts._ = merge config.services.nginx.sslTemplate {
|
virtualHosts._ = merge config.services.nginx.sslTemplate {
|
||||||
locations."/".return = "301 https://${domain}/404";
|
locations."/".return = "301 https://${fqdn}/404";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue