improve nginx logging

This commit is contained in:
Ingolf Wagner 2023-02-10 03:33:44 +01:00
parent e1614619fa
commit 860baf6203
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
3 changed files with 29 additions and 19 deletions

View file

@ -1,6 +1,7 @@
{ lib, config, pkgs, ... }: { { lib, config, pkgs, ... }: {
imports = [ imports = [
../../system/all/nginx.nix
../../system/all/borg-jobs.nix ../../system/all/borg-jobs.nix
../../system/all/defaults.nix ../../system/all/defaults.nix
../../system/all/syncthing.nix ../../system/all/syncthing.nix

View file

@ -108,23 +108,6 @@ in
}; };
}; };
# "stable-diffusion.ingolf-wagner.de" = {
# forceSSL = true;
# enableACME = true;
# extraConfig = error.extraConfig;
# root = "/srv/www/stable-diffusion";
# locations = {
# "/model-v1-4.ckpt" = {
# basicAuthFile = "${private_assets}/stable-diffusion-htpasswd";
# tryFiles = "/stable-diffusion-v-1-4-original/sd-v1-4.ckpt =404";
# };
# #"/model-v1-3.ckpt" = {
# # basicAuthFile = "${private_assets}/stable-diffusion-htpasswd";
# # tryFiles = "stable-diffusion-v-1-3-original/sd-v1-3.ckpt";
# #};
# } // error.locations;
# };
"travel.ingolf-wagner.de" = { "travel.ingolf-wagner.de" = {
forceSSL = true; forceSSL = true;
enableACME = true; enableACME = true;

View file

@ -1,7 +1,7 @@
{ pkgs, lib, ... }: { pkgs, lib, ... }:
let let
access_log_sink = "workhorse.private:12304"; access_log_sink = "<server>:<port>";
error_log_sink = "workhorse.private:12305"; error_log_sink = "<server>:<port>";
in in
{ {
@ -16,6 +16,32 @@ in
recommendedProxySettings = lib.mkDefault true; recommendedProxySettings = lib.mkDefault true;
recommendedTlsSettings = lib.mkDefault true; recommendedTlsSettings = lib.mkDefault true;
# for loki logging
commonHttpConfig = ''
log_format logfmt escape=json 'timestamp=$time_iso8601 '
'facility=nginx '
'src_addr=$remote_addr '
'body_bytes_sent=$body_bytes_sent '
'request_time=$request_time '
'response_status=$status '
'request="$request" '
'request_method="$request_method" '
'host="$host" '
'upstream_cache_status="$upstream_cache_status" '
'upstream_addr="$upstream_addr" '
'http_x_forwarded_for="$http_x_forwarded_for" '
'http_referrer="$http_referer" '
'http_user_agent="$http_user_agent"';
# log to local journald
access_log syslog:server=unix:/dev/log logfmt;
# to send logs somewhere
#access_log syslog:server=${access_log_sink} logfmt;
#error_log syslog:server=${error_log_sink};
'';
# for graylog logging # for graylog logging
#commonHttpConfig = '' #commonHttpConfig = ''
# log_format graylog2_json escape=json '{ "timestamp": "$time_iso8601", ' # log_format graylog2_json escape=json '{ "timestamp": "$time_iso8601", '