add options to log debug info in nginx
This commit is contained in:
parent
30a5e8b0e2
commit
831be9197c
2 changed files with 37 additions and 2 deletions
|
@ -9,14 +9,15 @@
|
|||
outputs = inputs@{ self, nixpkgs, sops-nix, ... }: {
|
||||
nixosModules.default = { config, ... }: {
|
||||
imports = [
|
||||
modules/ssl.nix
|
||||
modules/authelia.nix
|
||||
modules/backup.nix
|
||||
modules/home-assistant.nix
|
||||
modules/jellyfin.nix
|
||||
modules/ldap.nix
|
||||
modules/monitoring.nix
|
||||
modules/nextcloud-server.nix
|
||||
modules/ldap.nix
|
||||
modules/nginx.nix
|
||||
modules/ssl.nix
|
||||
];
|
||||
};
|
||||
|
||||
|
|
34
modules/nginx.nix
Normal file
34
modules/nginx.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.shb.nginx;
|
||||
in
|
||||
{
|
||||
options.shb.nginx = {
|
||||
accessLog = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
description = "Log all requests";
|
||||
default = false;
|
||||
example = true;
|
||||
};
|
||||
|
||||
debugLog = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
description = "Verbose debug of internal. This will print what servers were matched and why.";
|
||||
default = false;
|
||||
example = true;
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
services.nginx.logError = lib.mkIf cfg.debugLog "stderr warn";
|
||||
services.nginx.appendHttpConfig = lib.mkIf cfg.accessLog ''
|
||||
log_format postdata '$remote_addr - $remote_user [$time_local] '
|
||||
'"$request" <$server_name> $status $body_bytes_sent '
|
||||
'"$http_referer" "$http_user_agent" "$gzip_ratio" '
|
||||
'post:"$request_body"';
|
||||
|
||||
access_log syslog:server=unix:/dev/log postdata;
|
||||
'';
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue