Add: goaccess for blog
This commit is contained in:
parent
4eb2698dac
commit
9017181db2
4 changed files with 63 additions and 52 deletions
38
modules/services/goaccess.nix
Normal file
38
modules/services/goaccess.nix
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
{ pkgs, ... }: {
|
||||||
|
environment.systemPackages = with pkgs; [
|
||||||
|
goaccess
|
||||||
|
];
|
||||||
|
|
||||||
|
# Service pour générer le rapport statique GoAccess
|
||||||
|
systemd.services.goaccess-report = {
|
||||||
|
description = "Generate GoAccess HTML report";
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = "${pkgs.goaccess}/bin/goaccess /var/log/caddy/access-levr.porzh.me.log --log-format=CADDY -o /var/www/goaccess/index.html";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
# Timer pour régénérer le rapport toutes les heures
|
||||||
|
systemd.timers.goaccess-report = {
|
||||||
|
description = "Hourly GoAccess report generation";
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = "hourly";
|
||||||
|
Persistent = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
services.caddy = {
|
||||||
|
virtualHosts = {
|
||||||
|
"koum.porzh.me" = {
|
||||||
|
extraConfig = ''
|
||||||
|
root * /var/www/goaccess
|
||||||
|
file_server browse
|
||||||
|
try_files {path} {path}/ /index.html
|
||||||
|
|
||||||
|
${builtins.readFile ../../secrets/admin-passwd}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
{ pkgs, ...}:
|
|
||||||
{
|
|
||||||
services.nginx.enable = false ;
|
|
||||||
services.phpfpm.pools.nextcloud.settings."listen.owner" = "nextcloud";
|
|
||||||
services.phpfpm.pools.nextcloud.settings."listen.group" = "caddy";
|
|
||||||
services.phpfpm.pools.nextcloud.settings."listen.mode" = "0660";
|
|
||||||
services.caddy.virtualHosts."koum.porzh.me".extraConfig = ''
|
|
||||||
root * ${pkgs.nextcloud31}/
|
|
||||||
php_fastcgi unix//run/phpfpm/nextcloud.sock
|
|
||||||
file_server
|
|
||||||
|
|
||||||
header {
|
|
||||||
Strict-Transport-Security "max-age=31536000; includeSubDomains"
|
|
||||||
X-Content-Type-Options" "nosniff"
|
|
||||||
X-Frame-Options "SAMEORIGIN"
|
|
||||||
X-XSS-Protection "1; mode=block"
|
|
||||||
Referrer-Policy "same-origin"
|
|
||||||
# Permission-Policy "camera=(), moicrophone=(), geolocation=()"
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
services.nextcloud = {
|
|
||||||
enable = true ;
|
|
||||||
package = pkgs.nextcloud31;
|
|
||||||
hostName = "koum.porzh.me";
|
|
||||||
database.createLocally = true ;
|
|
||||||
config = {
|
|
||||||
dbtype = "sqlite";
|
|
||||||
adminpassFile="/home/lomig/.config/nextcloud.pass";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
{ config, pkgs, ... }:
|
{ config, pkgs, ... }:
|
||||||
{
|
{
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# 1️⃣ Caddy (reverse‑proxy / serveur web statique)
|
# 1️⃣ Caddy (reverse‑proxy / serveur web statique)
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
services.caddy = {
|
services.caddy = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
# Caddy démarre en tant qu’utilisateur « caddy ».
|
# Caddy démarre en tant qu’utilisateur « caddy ».
|
||||||
# On lui donne accès au répertoire du blog via les ACL créées plus haut.
|
# On lui donne accès au répertoire du blog via les ACL créées plus haut.
|
||||||
# (Pas besoin de config supplémentaire côté OS.)
|
# (Pas besoin de config supplémentaire côté OS.)
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# 2️⃣ Sites gérés par Caddy (Caddyfile intégré)
|
# 2️⃣ Sites gérés par Caddy (Caddyfile intégré)
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
virtualHosts = {
|
virtualHosts = {
|
||||||
"levr.porzh.me" = {
|
"levr.porzh.me" = {
|
||||||
# Le domaine sera automatiquement provisionné avec TLS via ACME
|
# Le domaine sera automatiquement provisionné avec TLS via ACME
|
||||||
# (Let's Encrypt) grâce à l’option `autoHTTPS = true` (défaut).
|
# (Let's Encrypt) grâce à l’option `autoHTTPS = true` (défaut).
|
||||||
# Aucun certificat manuel n’est requis.
|
# Aucun certificat manuel n’est requis.
|
||||||
|
|
||||||
# Le répertoire contenant les fichiers générés par Hugo
|
# Le répertoire contenant les fichiers générés par Hugo
|
||||||
|
|
||||||
# (Optionnel) Rediriger HTTP → HTTPS – Caddy le fait déjà,
|
# (Optionnel) Rediriger HTTP → HTTPS – Caddy le fait déjà,
|
||||||
# mais on le rend explicite pour la clarté.
|
# mais on le rend explicite pour la clarté.
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
@http {
|
@http {
|
||||||
protocol http
|
protocol http
|
||||||
|
|
@ -30,14 +30,18 @@
|
||||||
redir @http https://{host}{uri} permanent
|
redir @http https://{host}{uri} permanent
|
||||||
root * /srv/blog/public
|
root * /srv/blog/public
|
||||||
file_server
|
file_server
|
||||||
|
|
||||||
|
log {
|
||||||
|
output file /var/log/caddy/access-levr.porzh.me.log
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
# 3️⃣ Ouverture du firewall (ports 80 et 443)
|
# 3️⃣ Ouverture du firewall (ports 80 et 443)
|
||||||
# -----------------------------------------------------------------
|
# -----------------------------------------------------------------
|
||||||
networking.firewall.allowedTCPPorts = [
|
networking.firewall.allowedTCPPorts = [
|
||||||
80 # HTTP (pour la redirection ACME)
|
80 # HTTP (pour la redirection ACME)
|
||||||
443 # HTTPS (site final)
|
443 # HTTPS (site final)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
../modules/common/base.nix
|
../modules/common/base.nix
|
||||||
../modules/common/networking.nix
|
../modules/common/networking.nix
|
||||||
../modules/services/printing.nix
|
../modules/services/printing.nix
|
||||||
../modules/services/nextcloud.nix
|
../modules/services/goaccess.nix
|
||||||
../modules/sites/porzh.me.nix
|
../modules/sites/porzh.me.nix
|
||||||
../modules/sites/levr.porzh.me.nix
|
../modules/sites/levr.porzh.me.nix
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue