File tree Expand file tree Collapse file tree
config/nixos/applications Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{ config , lib , ... } :
2+ let
3+ logFormat = ''$remote_addr - $remote_user [$time_local] "$host" "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" rt=$request_time uct="$upstream_connect_time" uht="$upstream_header_time" urt="$upstream_response_time"'' ;
4+ in
25{
3- options . uwumarie . profiles . nginx = lib . mkEnableOption ( lib . mdDoc "nginx config" ) ;
6+ options . uwumarie . profiles . nginx . enable = lib . mkEnableOption ( lib . mdDoc "nginx config" ) ;
7+ options . uwumarie . profiles . nginx . monitoring . enable = lib . mkEnableOption ( lib . mdDoc "nginx monitoring" ) // {
8+ default = true ;
9+ } ;
410 options . services . nginx . virtualHosts = lib . mkOption {
511 type = lib . types . attrsOf ( lib . types . submodule {
612 config . forceSSL = lib . mkDefault true ;
713 config . http2 = lib . mkDefault true ;
814 config . useACMEHost = lib . mkDefault "marie.cologne" ;
915 } ) ;
1016 } ;
11- config = lib . mkIf config . uwumarie . profiles . nginx {
17+ config = lib . mkIf config . uwumarie . profiles . nginx . enable {
1218 services . nginx = {
1319 enable = true ;
1420 virtualHosts . "_" = {
1723 return = "404" ;
1824 } ;
1925 } ;
26+ virtualHosts . localhost = {
27+ forceSSL = false ;
28+ http2 = false ;
29+ useACMEHost = null ;
30+ } ;
2031 recommendedTlsSettings = true ;
2132 recommendedOptimisation = true ;
2233 recommendedGzipSettings = true ;
2334 recommendedBrotliSettings = true ;
2435 recommendedProxySettings = true ;
36+ appendHttpConfig = ''
37+ log_format meow '${ logFormat } ';
38+ access_log /var/log/nginx/access.log meow;
39+ '' ;
40+ } ;
41+
42+ services . prometheus . exporters . nginxlog = {
43+ enable = config . uwumarie . profiles . nginx . monitoring . enable ;
44+ group = "nginx" ;
45+ settings . namespaces = [
46+ {
47+ name = "nginx" ;
48+ format = logFormat ;
49+ source . files = [ "/var/log/nginx/access.log" ] ;
50+ }
51+ ] ;
2552 } ;
2653 } ;
2754}
Original file line number Diff line number Diff line change 1515 fail2ban = true ;
1616 openssh = true ;
1717 acme = true ;
18- nginx = true ;
18+ nginx . enable = true ;
1919 nix = true ;
2020 users . marie = true ;
2121 headless = true ;
Original file line number Diff line number Diff line change 8383 }
8484 ] ;
8585 }
86+ {
87+ job_name = "nginx" ;
88+ static_configs = [
89+ {
90+ targets = [ "localhost:9117" ] ;
91+ labels . instance = config . networking . hostName ;
92+ }
93+ {
94+ targets = [ "delphi:9117" ] ;
95+ labels . instance = "delphi" ;
96+ }
97+ ] ;
98+ }
8699 ( mkTarget {
87100 job = "ip-playground" ;
88101 target = "127.0.0.1:3032" ;
Original file line number Diff line number Diff line change 1414 uwumarie . profiles = {
1515 openssh = true ;
1616 acme = true ;
17- nginx = true ;
17+ nginx . enable = true ;
1818 nix = true ;
1919 users . marie = true ;
2020 headless = true ;
Original file line number Diff line number Diff line change 2929 uwumarie . profiles = {
3030 headless = true ;
3131 acme = true ;
32- nginx = true ;
32+ nginx . enable = true ;
3333 } ;
3434
3535 services . iperf3 = {
You can’t perform that action at this time.
0 commit comments