diff --git a/pkgs/servers/http/nginx/generic.nix b/pkgs/servers/http/nginx/generic.nix index 6563f5c1e159..a767cab27d11 100644 --- a/pkgs/servers/http/nginx/generic.nix +++ b/pkgs/servers/http/nginx/generic.nix @@ -230,10 +230,7 @@ stdenv.mkDerivation { [ # https://github.com/NixOS/nixpkgs/issues/357522 # https://github.com/zlib-ng/patches/blob/5a036c0a00120c75ee573b27f4f44ade80d82ff2/nginx/README.md - (fetchpatch { - url = "https://raw.githubusercontent.com/zlib-ng/patches/38756e6325a5d2cc32709b8e9549984c63a78815/nginx/1.26.2-zlib-ng.patch"; - hash = "sha256-LX5kP6jFiqgt4ApKw5eqOAFJNkc5QI6kX8ZRvBYTi9k="; - }) + ./nginx-zlib-ng.patch ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ (fetchpatch { diff --git a/pkgs/servers/http/nginx/mainline.nix b/pkgs/servers/http/nginx/mainline.nix index cd314ea48f8f..0060f6de1791 100644 --- a/pkgs/servers/http/nginx/mainline.nix +++ b/pkgs/servers/http/nginx/mainline.nix @@ -1,6 +1,6 @@ { callPackage, ... }@args: callPackage ./generic.nix args { - version = "1.27.3"; - hash = "sha256-uiOpVo9EIDa2HNDim9ZqR7kGNO+pHgss8tcZBXqbeQM="; + version = "1.27.4"; + hash = "sha256-KUgW+HmzAOYh+k7dU1PdHsALrbBWOZ7Osw3n22S3U7I="; } diff --git a/pkgs/servers/http/nginx/nginx-zlib-ng.patch b/pkgs/servers/http/nginx/nginx-zlib-ng.patch new file mode 100644 index 000000000000..0bda52411390 --- /dev/null +++ b/pkgs/servers/http/nginx/nginx-zlib-ng.patch @@ -0,0 +1,271 @@ +--- a/auto/lib/zlib/conf ++++ b/auto/lib/zlib/conf +@@ -33,8 +33,8 @@ if [ $ZLIB != NONE ]; then + + *) + have=NGX_ZLIB . auto/have +- LINK_DEPS="$LINK_DEPS $ZLIB/libz.a" +- CORE_LIBS="$CORE_LIBS $ZLIB/libz.a" ++ LINK_DEPS="$LINK_DEPS $ZLIB/libz-ng.a" ++ CORE_LIBS="$CORE_LIBS $ZLIB/libz-ng.a" + #CORE_LIBS="$CORE_LIBS -L $ZLIB -lz" + ;; + +@@ -50,10 +50,10 @@ else + ngx_feature="zlib library" + ngx_feature_name="NGX_ZLIB" + ngx_feature_run=no +- ngx_feature_incs="#include " ++ ngx_feature_incs="#include " + ngx_feature_path= +- ngx_feature_libs="-lz" +- ngx_feature_test="z_stream z; deflate(&z, Z_NO_FLUSH)" ++ ngx_feature_libs="-lz-ng" ++ ngx_feature_test="zng_stream z; zng_deflate(&z, Z_NO_FLUSH)" + . auto/feature + + +diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h +index 1861be6..bd427b8 100644 +--- a/src/core/ngx_config.h ++++ b/src/core/ngx_config.h +@@ -141,5 +141,9 @@ typedef intptr_t ngx_flag_t; + + #endif + ++/* Force enable ZLIB-NG */ ++#ifndef NGX_ZLIB_NG ++#define NGX_ZLIB_NG 1 ++#endif + + #endif /* _NGX_CONFIG_H_INCLUDED_ */ +diff --git a/src/http/modules/ngx_http_gunzip_filter_module.c b/src/http/modules/ngx_http_gunzip_filter_module.c +index 5d170a1..d8dcc96 100644 +--- a/src/http/modules/ngx_http_gunzip_filter_module.c ++++ b/src/http/modules/ngx_http_gunzip_filter_module.c +@@ -10,7 +10,14 @@ + #include + #include + +-#include ++#if defined(NGX_ZLIB_NG) ++# include ++# define ZPREFIX(x) zng_ ## x ++# define z_stream zng_stream ++#elif defined(NGX_ZLIB) ++# include ++# define ZPREFIX(x) x ++#endif + + + typedef struct { +@@ -312,7 +319,7 @@ ngx_http_gunzip_filter_inflate_start(ngx_http_request_t *r, + ctx->zstream.opaque = ctx; + + /* windowBits +16 to decode gzip, zlib 1.2.0.4+ */ +- rc = inflateInit2(&ctx->zstream, MAX_WBITS + 16); ++ rc = ZPREFIX(inflateInit2)(&ctx->zstream, MAX_WBITS + 16); + + if (rc != Z_OK) { + ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, +@@ -435,7 +442,7 @@ ngx_http_gunzip_filter_inflate(ngx_http_request_t *r, + ctx->zstream.avail_in, ctx->zstream.avail_out, + ctx->flush, ctx->redo); + +- rc = inflate(&ctx->zstream, ctx->flush); ++ rc = ZPREFIX(inflate)(&ctx->zstream, ctx->flush); + + if (rc != Z_OK && rc != Z_STREAM_END && rc != Z_BUF_ERROR) { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, +@@ -533,7 +540,7 @@ ngx_http_gunzip_filter_inflate(ngx_http_request_t *r, + + if (rc == Z_STREAM_END && ctx->zstream.avail_in > 0) { + +- rc = inflateReset(&ctx->zstream); ++ rc = ZPREFIX(inflateReset)(&ctx->zstream); + + if (rc != Z_OK) { + ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, +@@ -584,7 +591,7 @@ ngx_http_gunzip_filter_inflate_end(ngx_http_request_t *r, + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "gunzip inflate end"); + +- rc = inflateEnd(&ctx->zstream); ++ rc = ZPREFIX(inflateEnd)(&ctx->zstream); + + if (rc != Z_OK) { + ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, +diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c +index 7113df6..d6c2ea1 100644 +--- a/src/http/modules/ngx_http_gzip_filter_module.c ++++ b/src/http/modules/ngx_http_gzip_filter_module.c +@@ -9,7 +9,14 @@ + #include + #include + +-#include ++#if defined(NGX_ZLIB_NG) ++# include ++# define ZPREFIX(x) zng_ ## x ++# define z_stream zng_stream ++#elif defined(NGX_ZLIB) ++# include ++# define ZPREFIX(x) x ++#endif + + + typedef struct { +@@ -454,7 +461,7 @@ failed: + ctx->done = 1; + + if (ctx->preallocated) { +- deflateEnd(&ctx->zstream); ++ ZPREFIX(deflateEnd)(&ctx->zstream); + + ngx_pfree(r->pool, ctx->preallocated); + } +@@ -527,10 +534,20 @@ ngx_http_gzip_filter_memory(ngx_http_request_t *r, ngx_http_gzip_ctx_t *ctx) + wbits = ngx_max(wbits, 13); + } + +- ctx->allocated = 8192 + 16 + (1 << (wbits + 2)) +- + 131072 + (5 << (memlevel + 6)) +- + 4 * (64 + sizeof(void*)); + ctx->zlib_ng = 1; ++ ctx->allocated = 6144 // State ++ + 65536 // Window ++ + 65536 // Prev ++ + 131072 // Head ++ + 163840 // Pending ++ + 56 + 8 // Alloc struct + padding ++#if (defined(__s390__) || defined(__s390x__) || defined(__zarch__)) ++ + 4096 // Required to fix allocation alignment ++#else ++ + 64 // Required to fix allocation alignment ++#endif ++ + 256; // Extra to allow for future changes ++ + } + } + +@@ -623,7 +640,7 @@ ngx_http_gzip_filter_deflate_start(ngx_http_request_t *r, + ctx->zstream.zfree = ngx_http_gzip_filter_free; + ctx->zstream.opaque = ctx; + +- rc = deflateInit2(&ctx->zstream, (int) conf->level, Z_DEFLATED, ++ rc = ZPREFIX(deflateInit2)(&ctx->zstream, (int) conf->level, Z_DEFLATED, + ctx->wbits + 16, ctx->memlevel, Z_DEFAULT_STRATEGY); + + if (rc != Z_OK) { +@@ -758,7 +775,7 @@ ngx_http_gzip_filter_deflate(ngx_http_request_t *r, ngx_http_gzip_ctx_t *ctx) + ctx->zstream.avail_in, ctx->zstream.avail_out, + ctx->flush, ctx->redo); + +- rc = deflate(&ctx->zstream, ctx->flush); ++ rc = ZPREFIX(deflate)(&ctx->zstream, ctx->flush); + + if (rc != Z_OK && rc != Z_STREAM_END && rc != Z_BUF_ERROR) { + ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, +@@ -882,7 +899,7 @@ ngx_http_gzip_filter_deflate_end(ngx_http_request_t *r, + ctx->zin = ctx->zstream.total_in; + ctx->zout = ctx->zstream.total_out; + +- rc = deflateEnd(&ctx->zstream); ++ rc = ZPREFIX(deflateEnd)(&ctx->zstream); + + if (rc != Z_OK) { + ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, +diff --git a/src/http/modules/ngx_http_log_module.c b/src/http/modules/ngx_http_log_module.c +index f7c4bd2..ad71d4d 100644 +--- a/src/http/modules/ngx_http_log_module.c ++++ b/src/http/modules/ngx_http_log_module.c +@@ -9,8 +9,13 @@ + #include + #include + +-#if (NGX_ZLIB) +-#include ++#if defined(NGX_ZLIB_NG) ++# include ++# define ZPREFIX(x) zng_ ## x ++# define z_stream zng_stream ++#elif defined(NGX_ZLIB) ++# include ++# define ZPREFIX(x) x + #endif + + +@@ -634,7 +639,7 @@ ngx_http_log_gzip(ngx_fd_t fd, u_char *buf, size_t len, ngx_int_t level, + zstream.next_out = out; + zstream.avail_out = size; + +- rc = deflateInit2(&zstream, (int) level, Z_DEFLATED, wbits + 16, memlevel, ++ rc = ZPREFIX(deflateInit2)(&zstream, (int) level, Z_DEFLATED, wbits + 16, memlevel, + Z_DEFAULT_STRATEGY); + + if (rc != Z_OK) { +@@ -647,7 +652,7 @@ ngx_http_log_gzip(ngx_fd_t fd, u_char *buf, size_t len, ngx_int_t level, + zstream.next_in, zstream.next_out, + zstream.avail_in, zstream.avail_out); + +- rc = deflate(&zstream, Z_FINISH); ++ rc = ZPREFIX(deflate)(&zstream, Z_FINISH); + + if (rc != Z_STREAM_END) { + ngx_log_error(NGX_LOG_ALERT, log, 0, +@@ -663,7 +668,7 @@ ngx_http_log_gzip(ngx_fd_t fd, u_char *buf, size_t len, ngx_int_t level, + + size -= zstream.avail_out; + +- rc = deflateEnd(&zstream); ++ rc = ZPREFIX(deflateEnd)(&zstream); + + if (rc != Z_OK) { + ngx_log_error(NGX_LOG_ALERT, log, 0, "deflateEnd() failed: %d", rc); +diff --git a/src/stream/ngx_stream_log_module.c b/src/stream/ngx_stream_log_module.c +index 0ff7f42..0b9d12c 100644 +--- a/src/stream/ngx_stream_log_module.c ++++ b/src/stream/ngx_stream_log_module.c +@@ -9,8 +9,13 @@ + #include + #include + +-#if (NGX_ZLIB) +-#include ++#if defined(NGX_ZLIB_NG) ++# include ++# define ZPREFIX(x) zng_ ## x ++# define z_stream zng_stream ++#elif defined(NGX_ZLIB) ++# include ++# define ZPREFIX(x) x + #endif + + +@@ -525,7 +530,7 @@ ngx_stream_log_gzip(ngx_fd_t fd, u_char *buf, size_t len, ngx_int_t level, + zstream.next_out = out; + zstream.avail_out = size; + +- rc = deflateInit2(&zstream, (int) level, Z_DEFLATED, wbits + 16, memlevel, ++ rc = ZPREFIX(deflateInit2)(&zstream, (int) level, Z_DEFLATED, wbits + 16, memlevel, + Z_DEFAULT_STRATEGY); + + if (rc != Z_OK) { +@@ -538,7 +543,7 @@ ngx_stream_log_gzip(ngx_fd_t fd, u_char *buf, size_t len, ngx_int_t level, + zstream.next_in, zstream.next_out, + zstream.avail_in, zstream.avail_out); + +- rc = deflate(&zstream, Z_FINISH); ++ rc = ZPREFIX(deflate)(&zstream, Z_FINISH); + + if (rc != Z_STREAM_END) { + ngx_log_error(NGX_LOG_ALERT, log, 0, +@@ -554,7 +559,7 @@ ngx_stream_log_gzip(ngx_fd_t fd, u_char *buf, size_t len, ngx_int_t level, + + size -= zstream.avail_out; + +- rc = deflateEnd(&zstream); ++ rc = ZPREFIX(deflateEnd)(&zstream); + + if (rc != Z_OK) { + ngx_log_error(NGX_LOG_ALERT, log, 0, "deflateEnd() failed: %d", rc); diff --git a/pkgs/servers/http/nginx/stable.nix b/pkgs/servers/http/nginx/stable.nix index e1c69c4263b0..d331ba630117 100644 --- a/pkgs/servers/http/nginx/stable.nix +++ b/pkgs/servers/http/nginx/stable.nix @@ -1,6 +1,6 @@ { callPackage, ... }@args: callPackage ./generic.nix args { - version = "1.26.2"; - hash = "sha256-Yn/ghiCbuoCihToK3Z2VjX673/oahGeleEyaa08D1zg="; + version = "1.26.3"; + hash = "sha256-ae4rI3dEA25h0kuDZmiq0wQN2kYf5vVw8Xh+q1cMdao="; }