nixos/smokeping: Don't show 413 Forbidden on thttpd /. Fixes #197704

This commit is contained in:
Niklas Hambüchen 2022-10-25 15:53:43 +02:00 committed by Kerstin
parent ac6cf8a78b
commit f5c5386870
2 changed files with 13 additions and 0 deletions

View File

@ -318,6 +318,17 @@ in
description = "smokeping daemon user";
home = smokepingHome;
createHome = true;
# When `cfg.webService` is enabled, `thttpd` makes SmokePing available
# under `${cfg.host}:${cfg.port}/smokeping.fcgi` as per the `ln -s` below.
# We also want that going to `${cfg.host}:${cfg.port}` without `smokeping.fcgi`
# makes it easy for the user to find SmokePing.
# However `thttpd` does not seem to support easy redirections from `/` to `smokeping.fcgi`
# and only allows directory listings or `/` -> `index.html` resolution if the directory
# has `chmod 755` (see https://acme.com/software/thttpd/thttpd_man.html#PERMISSIONS,
# " directories should be 755 if you want to allow indexing").
# Otherwise it shows `403 Forbidden` on `/`.
# Thus, we need to make `smokepingHome` (which is given to `thttpd -d` below) `755`.
homeMode = "755";
};
users.groups.${cfg.user} = {};
systemd.services.smokeping = {

View File

@ -28,6 +28,8 @@ import ./make-test-python.nix ({ pkgs, ...} : {
sm.wait_for_unit("thttpd")
sm.wait_for_file("/var/lib/smokeping/data/Local/LocalMachine.rrd")
sm.succeed("curl -s -f localhost:8081/smokeping.fcgi?target=Local")
# Check that there's a helpful page without explicit path as well.
sm.succeed("curl -s -f localhost:8081")
sm.succeed("ls /var/lib/smokeping/cache/Local/LocalMachine_mini.png")
sm.succeed("ls /var/lib/smokeping/cache/index.html")
'';