diff options
Diffstat (limited to 'nixos/modules/services/web-servers/nginx/default.nix')
-rw-r--r-- | nixos/modules/services/web-servers/nginx/default.nix | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/nixos/modules/services/web-servers/nginx/default.nix b/nixos/modules/services/web-servers/nginx/default.nix index 6bc7192963d1..4e57b920a7d8 100644 --- a/nixos/modules/services/web-servers/nginx/default.nix +++ b/nixos/modules/services/web-servers/nginx/default.nix @@ -87,6 +87,8 @@ let server_tokens ${if cfg.serverTokens then "on" else "off"}; + ${cfg.commonHttpConfig} + ${vhosts} ${optionalString cfg.statusPage '' @@ -244,11 +246,13 @@ in }; package = mkOption { - default = pkgs.nginx; - defaultText = "pkgs.nginx"; + default = pkgs.nginxStable; + defaultText = "pkgs.nginxStable"; type = types.package; description = " - Nginx package to use. + Nginx package to use. This defaults to the stable version. Note + that the nginx team recommends to use the mainline version which + available in nixpkgs as <literal>nginxMainline</literal>. "; }; @@ -275,6 +279,24 @@ in ''; }; + commonHttpConfig = mkOption { + type = types.lines; + default = ""; + example = '' + resolver 127.0.0.1 valid=5s; + + log_format myformat '$remote_addr - $remote_user [$time_local] ' + '"$request" $status $body_bytes_sent ' + '"$http_referer" "$http_user_agent"'; + ''; + description = '' + With nginx you must provide common http context definitions before + they are used, e.g. log_format, resolver, etc. inside of server + or location contexts. Use this attribute to set these definitions + at the appropriate location. + ''; + }; + httpConfig = mkOption { type = types.lines; default = ""; |