Unverified Commit d856c037 authored by Izorkin's avatar Izorkin
Browse files

nixos/nginx: add option typesHashMaxSize

parent c47d1b14
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -129,12 +129,9 @@ let
  ''));

  commonHttpConfig = ''
      # Load mime types.
      # Load mime types and configure maximum size of the types hash tables.
      include ${cfg.defaultMimeTypes};
      # When recommendedOptimisation is disabled nginx fails to start because the mailmap mime.types database
      # contains 1026 entries and the default is only 1024. Setting to a higher number to remove the need to
      # overwrite it because nginx does not allow duplicated settings.
      types_hash_max_size 4096;
      types_hash_max_size ${toString cfg.typesHashMaxSize};

      include ${cfg.package}/conf/fastcgi.conf;
      include ${cfg.package}/conf/uwsgi_params;
@@ -896,6 +893,19 @@ in
          '';
      };

      typesHashMaxSize = mkOption {
        type = types.ints.positive;
        default = if cfg.defaultMimeTypes == "${pkgs.mailcap}/etc/nginx/mime.types" then 2688 else 1024;
        defaultText = literalExpression ''if cfg.defaultMimeTypes == "''${pkgs.mailcap}/etc/nginx/mime.types" then 2688 else 1024'';
        description = ''
          Sets the maximum size of the types hash tables (`types_hash_max_size`).
          It is recommended that the minimum size possible size is used.
          If {option}`recommendedOptimisation` is disabled, nginx would otherwise
          fail to start since the mailmap `mime.types` database has more entries
          than the nginx default value 1024.
        '';
      };

      proxyCachePath = mkOption {
        type = types.attrsOf (types.submodule ({ ... }: {
          options = {