about summary refs log tree commit diff
path: root/users/wpcarro/nixos/modules/nginx.nix
blob: e6cc6b0febab6ead9e394ae5c4d2d927f60722ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Common configuration for Nginx.
{ pkgs, ... }:

{
  config = {
    security.acme = {
      acceptTerms = true;
      defaults.email = "wpcarro@gmail.com";
    };

    services.nginx = {
      enable = true;
      enableReload = true;

      recommendedTlsSettings = true;
      recommendedGzipSettings = true;

      # Log errors to journald (i.e. /dev/log) with debug verbosity.
      logError = "syslog:server=unix:/dev/log debug";

      # for journaldriver
      commonHttpConfig = ''
        log_format json_combined escape=json
        '{'
            '"remote_addr":"$remote_addr",'
            '"method":"$request_method",'
            '"host":"$host",'
            '"uri":"$request_uri",'
            '"status":$status,'
            '"request_size":$request_length,'
            '"response_size":$body_bytes_sent,'
            '"response_time":$request_time,'
            '"referrer":"$http_referer",'
            '"user_agent":"$http_user_agent"'
        '}';

        access_log syslog:server=unix:/dev/log,nohostname json_combined;
      '';

      appendHttpConfig = ''
        add_header Permissions-Policy "interest-cohort=()";
      '';
    };
  };
}