mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/nginx: add option typesHashMaxSize (#341072)
This commit is contained in:
commit
e1635a35b9
4 changed files with 45 additions and 5 deletions
|
@ -129,12 +129,9 @@ let
|
||||||
''));
|
''));
|
||||||
|
|
||||||
commonHttpConfig = ''
|
commonHttpConfig = ''
|
||||||
# Load mime types.
|
# Load mime types and configure maximum size of the types hash tables.
|
||||||
include ${cfg.defaultMimeTypes};
|
include ${cfg.defaultMimeTypes};
|
||||||
# When recommendedOptimisation is disabled nginx fails to start because the mailmap mime.types database
|
types_hash_max_size ${toString cfg.typesHashMaxSize};
|
||||||
# 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;
|
|
||||||
|
|
||||||
include ${cfg.package}/conf/fastcgi.conf;
|
include ${cfg.package}/conf/fastcgi.conf;
|
||||||
include ${cfg.package}/conf/uwsgi_params;
|
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 {
|
proxyCachePath = mkOption {
|
||||||
type = types.attrsOf (types.submodule ({ ... }: {
|
type = types.attrsOf (types.submodule ({ ... }: {
|
||||||
options = {
|
options = {
|
||||||
|
|
|
@ -670,6 +670,7 @@ in {
|
||||||
nginx-etag-compression = handleTest ./nginx-etag-compression.nix {};
|
nginx-etag-compression = handleTest ./nginx-etag-compression.nix {};
|
||||||
nginx-globalredirect = handleTest ./nginx-globalredirect.nix {};
|
nginx-globalredirect = handleTest ./nginx-globalredirect.nix {};
|
||||||
nginx-http3 = handleTest ./nginx-http3.nix {};
|
nginx-http3 = handleTest ./nginx-http3.nix {};
|
||||||
|
nginx-mime = handleTest ./nginx-mime.nix {};
|
||||||
nginx-modsecurity = handleTest ./nginx-modsecurity.nix {};
|
nginx-modsecurity = handleTest ./nginx-modsecurity.nix {};
|
||||||
nginx-moreheaders = handleTest ./nginx-moreheaders.nix {};
|
nginx-moreheaders = handleTest ./nginx-moreheaders.nix {};
|
||||||
nginx-njs = handleTest ./nginx-njs.nix {};
|
nginx-njs = handleTest ./nginx-njs.nix {};
|
||||||
|
|
26
nixos/tests/nginx-mime.nix
Normal file
26
nixos/tests/nginx-mime.nix
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import ./make-test-python.nix (
|
||||||
|
{ lib, pkgs, ... }:
|
||||||
|
{
|
||||||
|
name = "nginx-mime";
|
||||||
|
meta.maintainers = with pkgs.lib.maintainers; [ izorkin ];
|
||||||
|
|
||||||
|
nodes = {
|
||||||
|
server =
|
||||||
|
{ pkgs, ... }:
|
||||||
|
{
|
||||||
|
services.nginx = {
|
||||||
|
enable = true;
|
||||||
|
virtualHosts."localhost" = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
server.start()
|
||||||
|
server.wait_for_unit("nginx")
|
||||||
|
# Check optimal size of types_hash
|
||||||
|
server.fail("journalctl --unit nginx --grep 'could not build optimal types_hash'")
|
||||||
|
server.shutdown()
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
)
|
|
@ -1,6 +1,7 @@
|
||||||
{ lib
|
{ lib
|
||||||
, stdenv
|
, stdenv
|
||||||
, fetchurl
|
, fetchurl
|
||||||
|
, nixosTests
|
||||||
|
|
||||||
# updater
|
# updater
|
||||||
, git
|
, git
|
||||||
|
@ -44,6 +45,8 @@ stdenv.mkDerivation rec {
|
||||||
exec nix-update --version "$VERSION" "$@"
|
exec nix-update --version "$VERSION" "$@"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
passthru.tests.nginx-mime = nixosTests.nginx-mime;
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "Helper application and MIME type associations for file types";
|
description = "Helper application and MIME type associations for file types";
|
||||||
homepage = "https://pagure.io/mailcap";
|
homepage = "https://pagure.io/mailcap";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue