git: 6f179278c66d - main - www/{nginx,nginx-devel,freenginx}: 3rd-party modules management

From: Jochen Neumeister <joneum_at_FreeBSD.org>
Date: Tue, 13 Oct 2026 21:21:03 UTC
The branch main has been updated by joneum:

URL: https://cgit.FreeBSD.org/ports/commit/?id=6f179278c66deb76f79e4c4844ee86dce0f6fb74

commit 6f179278c66deb76f79e4c4844ee86dce0f6fb74
Author:     Jochen Neumeister <joneum@FreeBSD.org>
AuthorDate: 2026-10-13 21:19:50 +0000
Commit:     Jochen Neumeister <joneum@FreeBSD.org>
CommitDate: 2026-10-13 21:20:47 +0000

    www/{nginx,nginx-devel,freenginx}: 3rd-party modules management
    
    Build the gridfs, postgres, redis2 and sflow modules from their own
    source ports instead of fetching them with GH_TUPLE.
    
    Sponsored by:   Netzkommune GmbH
---
 www/freenginx/Makefile                             | 32 ++++++++----
 www/freenginx/Makefile.extmod                      | 21 ++++----
 www/freenginx/distinfo                             |  8 ---
 .../files/extra-patch-nginx-gridfs_config          | 14 -----
 ...tra-patch-nginx-gridfs_ngx_http_gridfs_module.c | 21 --------
 .../files/extra-patch-ngx_http_sflow_config.c      | 10 ----
 .../files/extra-patch-ngx_http_sflow_config.h      | 11 ----
 .../files/extra-patch-ngx_http_sflow_module.c      | 59 ----------------------
 .../files/extra-patch-ngx_postgres-config          | 19 -------
 www/freenginx/pkg-plist                            |  1 +
 www/nginx-devel/Makefile                           | 32 ++++++++----
 www/nginx-devel/Makefile.extmod                    | 21 ++++----
 www/nginx-devel/distinfo                           |  8 ---
 .../files/extra-patch-nginx-gridfs_config          | 14 -----
 ...tra-patch-nginx-gridfs_ngx_http_gridfs_module.c | 21 --------
 .../files/extra-patch-ngx_http_sflow_config.c      | 10 ----
 .../files/extra-patch-ngx_http_sflow_config.h      | 11 ----
 .../files/extra-patch-ngx_http_sflow_module.c      | 56 --------------------
 .../files/extra-patch-ngx_postgres-config          | 19 -------
 www/nginx-devel/pkg-plist                          |  1 +
 www/nginx/Makefile                                 | 32 ++++++++----
 www/nginx/Makefile.extmod                          | 21 ++++----
 www/nginx/distinfo                                 |  8 ---
 www/nginx/files/extra-patch-nginx-gridfs_config    | 14 -----
 ...tra-patch-nginx-gridfs_ngx_http_gridfs_module.c | 21 --------
 .../files/extra-patch-ngx_http_sflow_config.c      | 10 ----
 .../files/extra-patch-ngx_http_sflow_config.h      | 11 ----
 .../files/extra-patch-ngx_http_sflow_module.c      | 59 ----------------------
 www/nginx/files/extra-patch-ngx_postgres-config    | 19 -------
 www/nginx/pkg-plist                                |  1 +
 30 files changed, 102 insertions(+), 483 deletions(-)

diff --git a/www/freenginx/Makefile b/www/freenginx/Makefile
index 83ee307c8ba8..2301c1b8ec86 100644
--- a/www/freenginx/Makefile
+++ b/www/freenginx/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	freenginx
 PORTVERSION=	${NGINX_VERSION}
 .include "version.mk"
-PORTREVISION?=	20
+PORTREVISION?=	21
 CATEGORIES=	www
 MASTER_SITES=	https://freenginx.org/download/ \
 		LOCAL/joneum
@@ -332,14 +332,6 @@ post-patch-PASSENGER-on:
 		s!-Iext/libeio!!' \
 		${WRKSRC_PASSENGER}/build/common_library.rb
 
-post-patch-POSTGRES-on:
-	@${REINPLACE_CMD} 's!%%PREFIX%%!${LOCALBASE}!g' ${WRKSRC_postgres}/config
-
-post-patch-SFLOW-on:
-	@${REINPLACE_CMD} \
-		's!%%PREFIX%%!${LOCALBASE}!g' \
-		${WRKSRC_sflow}/ngx_http_sflow_config.h
-
 pre-configure-SMALL_LIGHT-on:
 	( cd ${WRKSRC_small_light} && ./setup )
 
@@ -368,6 +360,11 @@ pre-configure-FORMINPUT-on:
 	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-form-input ${WRKSRC_forminput}
 	@${CHMOD} -R u+w ${WRKSRC_forminput}
 
+pre-configure-GRIDFS-on:
+	@${RM} -rf ${WRKSRC_gridfs}
+	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-gridfs ${WRKSRC_gridfs}
+	@${CHMOD} -R u+w ${WRKSRC_gridfs}
+
 pre-configure-LET-on:
 	@${RM} -rf ${WRKSRC_let}
 	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-let ${WRKSRC_let}
@@ -389,6 +386,23 @@ pre-configure-NJS-on:
 	@${CHMOD} -R u+w ${WRKSRC_njs}
 	@${CHMOD} u+x ${WRKSRC_njs}/configure
 
+pre-configure-POSTGRES-on:
+	@${RM} -rf ${WRKSRC_postgres}
+	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-postgres ${WRKSRC_postgres}
+	@${CHMOD} -R u+w ${WRKSRC_postgres}
+
+pre-configure-REDIS2-on:
+	@${RM} -rf ${WRKSRC_redis2}
+	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-redis2 ${WRKSRC_redis2}
+	@${CHMOD} -R u+w ${WRKSRC_redis2}
+
+pre-configure-SFLOW-on:
+	@${RM} -rf ${WRKSRC_sflow}
+	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-sflow ${WRKSRC_sflow}
+	@${CHMOD} -R u+w ${WRKSRC_sflow}
+	@${REINPLACE_CMD} 's!"/etc/hsflowd.auto"!"${LOCALBASE}/etc/hsflowd.auto"!' \
+		${WRKSRC_sflow}/src/ngx_http_sflow_config.h
+
 pre-configure-SLOWFS_CACHE-on:
 	@${RM} -rf ${WRKSRC_slowfs_cache}
 	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-slowfs-cache ${WRKSRC_slowfs_cache}
diff --git a/www/freenginx/Makefile.extmod b/www/freenginx/Makefile.extmod
index c2f33b2a8f7e..04184df844cb 100644
--- a/www/freenginx/Makefile.extmod
+++ b/www/freenginx/Makefile.extmod
@@ -73,13 +73,12 @@ FORMINPUT_BUILD_DEPENDS=	nginx-module-form-input>0:www/nginx-module-form-input
 WRKSRC_forminput=	${WRKDIR}/nginx-form-input-module
 FORMINPUT_VARS=		DSO_EXTMODS+=forminput
 
-GRIDFS_GH_TUPLE=	nieoding:nginx-gridfs:059bdc3:gridfs
 GRIDFS_LIB_DEPENDS=	libbson2.so:devel/libbson \
 			libmongoc2.so:devel/mongo-c-driver
 GRIDFS_USES=		pkgconfig
-GRIDFS_VARS=		DSO_EXTMODS+=gridfs GRIDFS_SUBDIR=/nginx-gridfs
-GRIDFS_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-nginx-gridfs_ngx_http_gridfs_module.c \
-			${PATCHDIR}/extra-patch-nginx-gridfs_config
+GRIDFS_BUILD_DEPENDS=	nginx-module-gridfs>0:www/nginx-module-gridfs
+WRKSRC_gridfs=		${WRKDIR}/nginx-gridfs-module
+GRIDFS_VARS=		DSO_EXTMODS+=gridfs
 
 HEADERS_MORE_GH_TUPLE=		openresty:headers-more-nginx-module:06dc0be:headers_more
 HEADERS_MORE_VARS=		DSO_EXTMODS+=headers_more
@@ -296,8 +295,8 @@ PASSENGER_VARS=         WRKSRC_passenger=${WRKDIR}/passenger-${PASSENGER_NGINX_V
                         DSO_EXTDIRS+=passenger-${PASSENGER_NGINX_VER}/src/nginx_module
 
 POSTGRES_USES=		pgsql
-POSTGRES_GH_TUPLE=	konstruxi:ngx_postgres:8aa7359:postgres
-POSTGRES_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-ngx_postgres-config
+POSTGRES_BUILD_DEPENDS=	nginx-module-postgres>0:www/nginx-module-postgres
+WRKSRC_postgres=	${WRKDIR}/nginx-postgres-module
 POSTGRES_VARS=		DSO_EXTMODS+=postgres
 
 RDS_CSV_GH_TUPLE=	openresty:rds-csv-nginx-module:v0.09:rdscsv
@@ -308,7 +307,8 @@ RDS_JSON_GH_TUPLE=	openresty:rds-json-nginx-module:v0.15:rdsjson
 RDS_JSON_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-rds-json-nginx-module-config
 RDS_JSON_VARS=		DSO_EXTMODS+=rdsjson
 
-REDIS2_GH_TUPLE=	openresty:redis2-nginx-module:v0.15:redis2
+REDIS2_BUILD_DEPENDS=	nginx-module-redis2>0:www/nginx-module-redis2
+WRKSRC_redis2=		${WRKDIR}/nginx-redis2-module
 REDIS2_VARS=		DSO_EXTMODS+=redis2
 
 RTMP_GH_TUPLE=		arut:nginx-rtmp-module:v1.2.2:rtmp
@@ -318,10 +318,9 @@ SET_MISC_IMPLIES=	DEVEL_KIT
 SET_MISC_GH_TUPLE=	openresty:set-misc-nginx-module:3937e7b:setmisc
 SET_MISC_VARS=		DSO_EXTMODS+=setmisc
 
-SFLOW_GH_TUPLE=		sflow:nginx-sflow-module:543c72a:sflow
-SFLOW_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-ngx_http_sflow_config.c \
-			${PATCHDIR}/extra-patch-ngx_http_sflow_config.h \
-			${PATCHDIR}/extra-patch-ngx_http_sflow_module.c
+SFLOW_BUILD_DEPENDS=	nginx-module-sflow>0:www/nginx-module-sflow
+WRKSRC_sflow=		${WRKDIR}/nginx-sflow-module
+SFLOW_VARS=		DSO_EXTMODS+=sflow
 
 SHIBBOLETH_GH_TUPLE=	nginx-shib:nginx-http-shibboleth:be12df5:shibboleth
 SHIBBOLETH_VARS=	DSO_EXTMODS+=shibboleth
diff --git a/www/freenginx/distinfo b/www/freenginx/distinfo
index 68ea0d028f72..f0205b88c958 100644
--- a/www/freenginx/distinfo
+++ b/www/freenginx/distinfo
@@ -23,8 +23,6 @@ SHA256 (openresty-encrypted-session-nginx-module-v0.09_GH0.tar.gz) = fe9b95acf97
 SIZE (openresty-encrypted-session-nginx-module-v0.09_GH0.tar.gz) = 11847
 SHA256 (ogarrett-nginx-fips-check-module-6cb4270_GH0.tar.gz) = d52fbb0f2819cd91b710ad85e6c8b452fdca6a5d81b0694d6637adba3fc2382c
 SIZE (ogarrett-nginx-fips-check-module-6cb4270_GH0.tar.gz) = 6494
-SHA256 (nieoding-nginx-gridfs-059bdc3_GH0.tar.gz) = 9b059b5ae7b602d12d32d5ebe2700827ea625f22c0fb3b9956242e11de63845b
-SIZE (nieoding-nginx-gridfs-059bdc3_GH0.tar.gz) = 4674
 SHA256 (openresty-headers-more-nginx-module-06dc0be_GH0.tar.gz) = 883b1e31d59f3eb1e76b34259711ad65a3443102973dcf22df329397f3d5eaa4
 SIZE (openresty-headers-more-nginx-module-06dc0be_GH0.tar.gz) = 29438
 SHA256 (dvershinin-nginx_accept_language_module-5683967_GH0.tar.gz) = a58feb576f2231498b8a3863d3c6fba45c7d48bc48735fa714e07a7bfbedb6e3
@@ -91,20 +89,14 @@ SHA256 (libinjection-libinjection-4aa3894_GH0.tar.gz) = ededea133e89e238ef2e60d0
 SIZE (libinjection-libinjection-4aa3894_GH0.tar.gz) = 2218294
 SHA256 (osokin-nginx-otel-51273ec_GH0.tar.gz) = a2107ba0be94c8561ae50773163c7946a58e508be46920f588d05a347c867d9c
 SIZE (osokin-nginx-otel-51273ec_GH0.tar.gz) = 28076
-SHA256 (konstruxi-ngx_postgres-8aa7359_GH0.tar.gz) = c69ad4495de7c7883ebc23e1e6c4cc83a4ac6a7fddd4d5c12e49d33b65f7c50b
-SIZE (konstruxi-ngx_postgres-8aa7359_GH0.tar.gz) = 48544
 SHA256 (openresty-rds-csv-nginx-module-v0.09_GH0.tar.gz) = 896be99c0cad50218417800a159e43ec088d6b58c099472ed3b3d7f179d6c0ea
 SIZE (openresty-rds-csv-nginx-module-v0.09_GH0.tar.gz) = 20531
 SHA256 (openresty-rds-json-nginx-module-v0.15_GH0.tar.gz) = eaf18f60e981ea2442a7902689a26eba6cf6f36ebee712feeb1f4429eb654bdc
 SIZE (openresty-rds-json-nginx-module-v0.15_GH0.tar.gz) = 34744
-SHA256 (openresty-redis2-nginx-module-v0.15_GH0.tar.gz) = d255571bcfb9939b78099df39cb4d42f174d789aec8c8e5e47b93942b0299438
-SIZE (openresty-redis2-nginx-module-v0.15_GH0.tar.gz) = 25471
 SHA256 (arut-nginx-rtmp-module-v1.2.2_GH0.tar.gz) = 07f19b7bffec5e357bb8820c63e5281debd45f5a2e6d46b1636d9202c3e09d78
 SIZE (arut-nginx-rtmp-module-v1.2.2_GH0.tar.gz) = 519934
 SHA256 (openresty-set-misc-nginx-module-3937e7b_GH0.tar.gz) = cb3a4675ab6b8741e5847cf5bc41ee3f6ec5cbceec53188f9ae96e48feea17c5
 SIZE (openresty-set-misc-nginx-module-3937e7b_GH0.tar.gz) = 29335
-SHA256 (sflow-nginx-sflow-module-543c72a_GH0.tar.gz) = 95efdb1f6cfd6c32c577707f693eb6795c6f21ae062842bf84fe762d8b842955
-SIZE (sflow-nginx-sflow-module-543c72a_GH0.tar.gz) = 29504
 SHA256 (nginx-shib-nginx-http-shibboleth-be12df5_GH0.tar.gz) = aff9830b5de78dd9ce32cd2c55c5cf9173c99fe1a1d2190407c96668e7517bab
 SIZE (nginx-shib-nginx-http-shibboleth-be12df5_GH0.tar.gz) = 23872
 SHA256 (openresty-srcache-nginx-module-be22ac0_GH0.tar.gz) = 5753d1ffe87b5d6f5b7a0696667bb5ff1388738136fdee26ba55bc33f5796061
diff --git a/www/freenginx/files/extra-patch-nginx-gridfs_config b/www/freenginx/files/extra-patch-nginx-gridfs_config
deleted file mode 100644
index 730af5a858f9..000000000000
--- a/www/freenginx/files/extra-patch-nginx-gridfs_config
+++ /dev/null
@@ -1,14 +0,0 @@
---- ../nginx-gridfs-059bdc3/nginx-gridfs/config.orig	2026-07-07 12:40:20.001344000 +0000
-+++ ../nginx-gridfs-059bdc3/nginx-gridfs/config	2026-07-07 12:41:06.850920000 +0000
-@@ -1,7 +1,7 @@
- ngx_module_type=HTTP
- ngx_module_name=ngx_http_gridfs_module
--ngx_module_incs="/usr/include/libmongoc-1.0 /usr/include/libbson-1.0"
--ngx_module_libs="-lmongoc-1.0 -lbson-1.0"
-+ngx_module_incs=`pkg-config --cflags-only-I mongoc2 bson2 | sed -e 's/-I//g'`
-+ngx_module_libs=`pkg-config --libs mongoc2 bson2`
- ngx_module_srcs="$ngx_addon_dir/ngx_http_gridfs_module.c"
- . auto/module
--ngx_addon_name=$ngx_module_name
-\ No newline at end of file
-+ngx_addon_name=$ngx_module_name
diff --git a/www/freenginx/files/extra-patch-nginx-gridfs_ngx_http_gridfs_module.c b/www/freenginx/files/extra-patch-nginx-gridfs_ngx_http_gridfs_module.c
deleted file mode 100644
index 2471ad2c99e6..000000000000
--- a/www/freenginx/files/extra-patch-nginx-gridfs_ngx_http_gridfs_module.c
+++ /dev/null
@@ -1,21 +0,0 @@
---- ../nginx-gridfs-059bdc3/nginx-gridfs/ngx_http_gridfs_module.c.orig	2018-01-20 07:53:32.000000000 +0000
-+++ ../nginx-gridfs-059bdc3/nginx-gridfs/ngx_http_gridfs_module.c	2026-07-07 14:27:08.501699000 +0000
-@@ -1,7 +1,8 @@
- #include <ngx_config.h>
- #include <ngx_core.h>
- #include <ngx_http.h>
--#include <mongoc.h>
-+#include <mongoc/mongoc.h>
-+#include <assert.h>
- #include <signal.h>
- #include <stdio.h>
- 
-@@ -361,7 +361,7 @@
-     bson_init(&filter);
-     bson_oid_init_from_string(&oid, (const char*)value);
-     bson_append_oid(&filter, "_id", -1, &oid);
--    gfile = mongoc_gridfs_find_one(gridfs, &filter, &error);
-+    gfile = mongoc_gridfs_find_one_with_opts(gridfs, &filter, NULL, &error);
- 
-     bson_destroy (&filter);
- 
diff --git a/www/freenginx/files/extra-patch-ngx_http_sflow_config.c b/www/freenginx/files/extra-patch-ngx_http_sflow_config.c
deleted file mode 100644
index 3e3eaa2260f5..000000000000
--- a/www/freenginx/files/extra-patch-ngx_http_sflow_config.c
+++ /dev/null
@@ -1,10 +0,0 @@
---- ../nginx-sflow-module-543c72a/ngx_http_sflow_config.c.orig	2012-06-07 04:52:57.000000000 +0400
-+++ ../nginx-sflow-module-543c72a/ngx_http_sflow_config.c	2012-06-07 04:59:18.000000000 +0400
-@@ -26,7 +26,6 @@
-         ngx_log_error(NGX_LOG_ERR, log, 0, "getaddrinfo() failed: %s", gai_strerror(err));
-         switch(err) {
-         case EAI_NONAME: break;
--        case EAI_NODATA: break;
-         case EAI_AGAIN: break; // loop and try again?
-         default: ngx_log_error(NGX_LOG_ERR, log, 0, "getaddrinfo() error: %s", gai_strerror(err)); break;
-         }
diff --git a/www/freenginx/files/extra-patch-ngx_http_sflow_config.h b/www/freenginx/files/extra-patch-ngx_http_sflow_config.h
deleted file mode 100644
index 6b90d4eaaf14..000000000000
--- a/www/freenginx/files/extra-patch-ngx_http_sflow_config.h
+++ /dev/null
@@ -1,11 +0,0 @@
---- ../nginx-sflow-module-543c72a/ngx_http_sflow_config.h.orig	2012-07-31 21:36:49.000000000 +0400
-+++ ../nginx-sflow-module-543c72a/ngx_http_sflow_config.h	2012-07-31 21:37:20.000000000 +0400
-@@ -17,7 +17,7 @@
-   -----------------___________________________------------------
- */
- 
--#define SFWB_DEFAULT_CONFIGFILE "/etc/hsflowd.auto"
-+#define SFWB_DEFAULT_CONFIGFILE "%%PREFIX%%/etc/hsflowd.auto"
- #define SFWB_SEPARATORS " \t\r\n="
- #define SFWB_QUOTES "'\" \t\r\n"
- /* SFWB_MAX LINE LEN must be enough to hold the whole list of targets */
diff --git a/www/freenginx/files/extra-patch-ngx_http_sflow_module.c b/www/freenginx/files/extra-patch-ngx_http_sflow_module.c
deleted file mode 100644
index e6b4bad6e25f..000000000000
--- a/www/freenginx/files/extra-patch-ngx_http_sflow_module.c
+++ /dev/null
@@ -1,59 +0,0 @@
---- ../nginx-sflow-module-543c72a/ngx_http_sflow_module.c.orig	2014-09-24 18:20:41.000000000 -0400
-+++ ../nginx-sflow-module-543c72a/ngx_http_sflow_module.c	2016-08-06 21:26:24.515559000 -0400
-@@ -8,9 +8,6 @@
- #include <ngx_http.h>
- #include <nginx.h>
- 
--#if (NGX_THREADS)
--#include <ngx_thread.h>
--#endif
- 
- #include "ngx_http_sflow_api.h"
- #include "ngx_http_sflow_config.h"
-@@ -74,18 +71,10 @@
-     /* keep log ptr for callbacks */
-     ngx_log_t *log;
- 
--#if (NGX_THREADS)
--    ngx_mutex_t *mut;
--#define SFWB_LOCK(_s) ngx_mutex_lock((_s)->mut)
--#define SFWB_UNLOCK(_s) ngx_mutex_unlock((_s)->mut)
--#define SFWB_INC_CTR(_c) ngx_atomic_fetch_add(&(_c), 1)
--#define SFWB_COUNTDOWN(_c) (ngx_atomic_fetch_add(&(_c), -1) == 1)
--#else
- #define SFWB_LOCK(_s) /* no-op */
- #define SFWB_UNLOCK(_s) /* no-op */
- #define SFWB_INC_CTR(_c) (_c)++
- #define SFWB_COUNTDOWN(_c) (--(_c) == 0)
--#endif
- 
-     /* skip countdown is handled per-worker to reduce lock contention.
-      * If all processes sample at 1:N it's the same as having only one
-@@ -645,13 +634,8 @@
- {
-     sm->random_seed  = ((sm->random_seed * 32719) + 3) % 32749;
-     ngx_atomic_t next_skip = (sm->random_seed % ((2 * sm->sampling_rate) - 1)) + 1;
--#if (NGX_THREADS)
--    ngx_atomic_int_t test_skip = ngx_atomic_fetch_add(&sm->sflow_skip, next_skip);
--    return (test_skip + next_skip);
--#else
-     sm->sflow_skip = next_skip;
-     return next_skip;
--#endif
- }
- 
- /*_________________---------------------------__________________
-@@ -864,13 +848,6 @@
- {
-     ngx_log_debug0(NGX_LOG_DEBUG_HTTP, cf->log, 0, "sflow: sfwb_init()");
- 
--#if (NGX_THREADS)
--    /* a mutex to lock the sFlow agent when taking a sample (only needed if there
--     * is more that one worker thread - right now it seems like threads are not even
--     * an option in the configure script)
--     */
--    sm->mut = ngx_mutex_init(cf->log, 0);
--#endif
- 
-     /* look up some vars by name and cache the index numbers -- see ngx_http_variables.c */
-     ngx_str_t str_uri = ngx_string("request_uri"); /* the "unparsed" variant */
diff --git a/www/freenginx/files/extra-patch-ngx_postgres-config b/www/freenginx/files/extra-patch-ngx_postgres-config
deleted file mode 100644
index 8c26c0f7dd64..000000000000
--- a/www/freenginx/files/extra-patch-ngx_postgres-config
+++ /dev/null
@@ -1,19 +0,0 @@
---- ../ngx_postgres-8aa7359/config.orig	2015-05-26 20:52:25.649166000 +0300
-+++ ../ngx_postgres-8aa7359/config	2015-05-26 20:53:10.331122000 +0300
-@@ -48,12 +48,12 @@
- 
-     if [ $ngx_found = no ]; then
-         # FreeBSD
--        ngx_feature="libpq library in /usr/local/"
--        ngx_feature_path="/usr/local/include"
-+        ngx_feature="libpq library in %%PREFIX%%/"
-+        ngx_feature_path="%%PREFIX%%/include"
-         if [ $NGX_RPATH = YES ]; then
--            ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lpq"
-+            ngx_feature_libs="-R%%PREFIX%%/lib -L%%PREFIX%%/lib -lpq"
-         else
--            ngx_feature_libs="-L/usr/local/lib -lpq"
-+            ngx_feature_libs="-L%%PREFIX%%/lib -lpq"
-         fi
-         . auto/feature
-     fi
diff --git a/www/freenginx/pkg-plist b/www/freenginx/pkg-plist
index 200a8eaa786b..ef7d2019e27a 100644
--- a/www/freenginx/pkg-plist
+++ b/www/freenginx/pkg-plist
@@ -73,6 +73,7 @@
 %%DSO%%%%REDIS2%%libexec/freenginx/ngx_http_redis2_module.so
 %%DSO%%%%RTMP%%libexec/freenginx/ngx_rtmp_module.so
 %%DSO%%%%SET_MISC%%libexec/freenginx/ngx_http_set_misc_module.so
+%%DSO%%%%SFLOW%%libexec/freenginx/ngx_http_sflow_module.so
 %%DSO%%%%SHIBBOLETH%%libexec/freenginx/ngx_http_shibboleth_module.so
 %%DSO%%%%SLOWFS_CACHE%%libexec/freenginx/ngx_http_slowfs_module.so
 %%DSO%%%%SRCACHE%%libexec/freenginx/ngx_http_srcache_filter_module.so
diff --git a/www/nginx-devel/Makefile b/www/nginx-devel/Makefile
index c7d40c8ef9cc..ba7c18415fae 100644
--- a/www/nginx-devel/Makefile
+++ b/www/nginx-devel/Makefile
@@ -1,7 +1,7 @@
 PORTNAME?=	nginx
 PORTVERSION=	${NGINX_VERSION}
 .include "version.mk"
-PORTREVISION=	4
+PORTREVISION=	5
 CATEGORIES=	www
 MASTER_SITES=	https://nginx.org/download/
 PKGNAMESUFFIX?=	-devel
@@ -342,14 +342,6 @@ post-patch-PASSENGER-on:
 		s!-Iext/libeio!!' \
 		${WRKSRC_PASSENGER}/build/common_library.rb
 
-post-patch-POSTGRES-on:
-	@${REINPLACE_CMD} 's!%%PREFIX%%!${LOCALBASE}!g' ${WRKSRC_postgres}/config
-
-post-patch-SFLOW-on:
-	@${REINPLACE_CMD} \
-		's!%%PREFIX%%!${LOCALBASE}!g' \
-		${WRKSRC_sflow}/ngx_http_sflow_config.h
-
 pre-configure-SMALL_LIGHT-on:
 	( cd ${WRKSRC_small_light} && ./setup )
 
@@ -378,6 +370,11 @@ pre-configure-FORMINPUT-on:
 	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-form-input ${WRKSRC_forminput}
 	@${CHMOD} -R u+w ${WRKSRC_forminput}
 
+pre-configure-GRIDFS-on:
+	@${RM} -rf ${WRKSRC_gridfs}
+	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-gridfs ${WRKSRC_gridfs}
+	@${CHMOD} -R u+w ${WRKSRC_gridfs}
+
 pre-configure-LET-on:
 	@${RM} -rf ${WRKSRC_let}
 	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-let ${WRKSRC_let}
@@ -399,6 +396,23 @@ pre-configure-NJS-on:
 	@${CHMOD} -R u+w ${WRKSRC_njs}
 	@${CHMOD} u+x ${WRKSRC_njs}/configure
 
+pre-configure-POSTGRES-on:
+	@${RM} -rf ${WRKSRC_postgres}
+	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-postgres ${WRKSRC_postgres}
+	@${CHMOD} -R u+w ${WRKSRC_postgres}
+
+pre-configure-REDIS2-on:
+	@${RM} -rf ${WRKSRC_redis2}
+	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-redis2 ${WRKSRC_redis2}
+	@${CHMOD} -R u+w ${WRKSRC_redis2}
+
+pre-configure-SFLOW-on:
+	@${RM} -rf ${WRKSRC_sflow}
+	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-sflow ${WRKSRC_sflow}
+	@${CHMOD} -R u+w ${WRKSRC_sflow}
+	@${REINPLACE_CMD} 's!"/etc/hsflowd.auto"!"${LOCALBASE}/etc/hsflowd.auto"!' \
+		${WRKSRC_sflow}/src/ngx_http_sflow_config.h
+
 pre-configure-SLOWFS_CACHE-on:
 	@${RM} -rf ${WRKSRC_slowfs_cache}
 	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-slowfs-cache ${WRKSRC_slowfs_cache}
diff --git a/www/nginx-devel/Makefile.extmod b/www/nginx-devel/Makefile.extmod
index 159b279af44f..c95fc101a062 100644
--- a/www/nginx-devel/Makefile.extmod
+++ b/www/nginx-devel/Makefile.extmod
@@ -66,13 +66,12 @@ FORMINPUT_BUILD_DEPENDS=	nginx-module-form-input>0:www/nginx-module-form-input
 WRKSRC_forminput=	${WRKDIR}/nginx-form-input-module
 FORMINPUT_VARS=		DSO_EXTMODS+=forminput
 
-GRIDFS_GH_TUPLE=	nieoding:nginx-gridfs:059bdc3:gridfs
 GRIDFS_LIB_DEPENDS=	libbson2.so:devel/libbson \
 			libmongoc2.so:devel/mongo-c-driver
 GRIDFS_USES=		pkgconfig
-GRIDFS_VARS=		DSO_EXTMODS+=gridfs GRIDFS_SUBDIR=/nginx-gridfs
-GRIDFS_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-nginx-gridfs_ngx_http_gridfs_module.c \
-			${PATCHDIR}/extra-patch-nginx-gridfs_config
+GRIDFS_BUILD_DEPENDS=	nginx-module-gridfs>0:www/nginx-module-gridfs
+WRKSRC_gridfs=		${WRKDIR}/nginx-gridfs-module
+GRIDFS_VARS=		DSO_EXTMODS+=gridfs
 
 HEADERS_MORE_GH_TUPLE=		openresty:headers-more-nginx-module:v0.39:headers_more
 HEADERS_MORE_VARS=		DSO_EXTMODS+=headers_more
@@ -294,8 +293,8 @@ PASSENGER_VARS=		WRKSRC_passenger=${WRKDIR}/passenger-${PASSENGER_NGINX_VER} \
 			DSO_EXTDIRS+=passenger-${PASSENGER_NGINX_VER}/src/nginx_module
 
 POSTGRES_USES=		pgsql
-POSTGRES_GH_TUPLE=	konstruxi:ngx_postgres:8aa7359:postgres
-POSTGRES_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-ngx_postgres-config
+POSTGRES_BUILD_DEPENDS=	nginx-module-postgres>0:www/nginx-module-postgres
+WRKSRC_postgres=	${WRKDIR}/nginx-postgres-module
 POSTGRES_VARS=		DSO_EXTMODS+=postgres
 
 RDS_CSV_GH_TUPLE=	openresty:rds-csv-nginx-module:6a90686:rdscsv
@@ -305,7 +304,8 @@ RDS_CSV_VARS=		DSO_EXTMODS+=rdscsv
 RDS_JSON_GH_TUPLE=	openresty:rds-json-nginx-module:e6517b9:rdsjson
 RDS_JSON_VARS=		DSO_EXTMODS+=rdsjson
 
-REDIS2_GH_TUPLE=	openresty:redis2-nginx-module:454c223:redis2
+REDIS2_BUILD_DEPENDS=	nginx-module-redis2>0:www/nginx-module-redis2
+WRKSRC_redis2=		${WRKDIR}/nginx-redis2-module
 REDIS2_VARS=		DSO_EXTMODS+=redis2
 
 RTMP_GH_TUPLE=		arut:nginx-rtmp-module:6c7719d:rtmp
@@ -315,10 +315,9 @@ SET_MISC_IMPLIES=	DEVEL_KIT
 SET_MISC_GH_TUPLE=	openresty:set-misc-nginx-module:eb223c9:setmisc
 SET_MISC_VARS=		DSO_EXTMODS+=setmisc
 
-SFLOW_GH_TUPLE=		sflow:nginx-sflow-module:f15c87f:sflow
-SFLOW_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-ngx_http_sflow_config.c \
-			${PATCHDIR}/extra-patch-ngx_http_sflow_config.h \
-			${PATCHDIR}/extra-patch-ngx_http_sflow_module.c
+SFLOW_BUILD_DEPENDS=	nginx-module-sflow>0:www/nginx-module-sflow
+WRKSRC_sflow=		${WRKDIR}/nginx-sflow-module
+SFLOW_VARS=		DSO_EXTMODS+=sflow
 
 SHIBBOLETH_GH_TUPLE=	nginx-shib:nginx-http-shibboleth:629ae1f:shibboleth
 SHIBBOLETH_VARS=	DSO_EXTMODS+=shibboleth
diff --git a/www/nginx-devel/distinfo b/www/nginx-devel/distinfo
index 00466ff667ed..a075e4f4f761 100644
--- a/www/nginx-devel/distinfo
+++ b/www/nginx-devel/distinfo
@@ -19,8 +19,6 @@ SHA256 (openresty-encrypted-session-nginx-module-7ffe4ec_GH0.tar.gz) = 1848ee88b
 SIZE (openresty-encrypted-session-nginx-module-7ffe4ec_GH0.tar.gz) = 11899
 SHA256 (ogarrett-nginx-fips-check-module-6cb4270_GH0.tar.gz) = d52fbb0f2819cd91b710ad85e6c8b452fdca6a5d81b0694d6637adba3fc2382c
 SIZE (ogarrett-nginx-fips-check-module-6cb4270_GH0.tar.gz) = 6494
-SHA256 (nieoding-nginx-gridfs-059bdc3_GH0.tar.gz) = 9b059b5ae7b602d12d32d5ebe2700827ea625f22c0fb3b9956242e11de63845b
-SIZE (nieoding-nginx-gridfs-059bdc3_GH0.tar.gz) = 4674
 SHA256 (openresty-headers-more-nginx-module-v0.39_GH0.tar.gz) = dde68d3fa2a9fc7f52e436d2edc53c6d703dcd911283965d889102d3a877c778
 SIZE (openresty-headers-more-nginx-module-v0.39_GH0.tar.gz) = 29616
 SHA256 (dvershinin-nginx_accept_language_module-5683967_GH0.tar.gz) = a58feb576f2231498b8a3863d3c6fba45c7d48bc48735fa714e07a7bfbedb6e3
@@ -93,20 +91,14 @@ SHA256 (libinjection-libinjection-b9fcaaf_GH0.tar.gz) = 7812e1316b61a7a7d3a65a57
 SIZE (libinjection-libinjection-b9fcaaf_GH0.tar.gz) = 2218207
 SHA256 (osokin-nginx-otel-3a655df_GH0.tar.gz) = 71ee1561303c289d4562148f8719b60796c36abe16de1b3c10d10b8e6f03a952
 SIZE (osokin-nginx-otel-3a655df_GH0.tar.gz) = 27169
-SHA256 (konstruxi-ngx_postgres-8aa7359_GH0.tar.gz) = c69ad4495de7c7883ebc23e1e6c4cc83a4ac6a7fddd4d5c12e49d33b65f7c50b
-SIZE (konstruxi-ngx_postgres-8aa7359_GH0.tar.gz) = 48544
 SHA256 (openresty-rds-csv-nginx-module-6a90686_GH0.tar.gz) = 92068b96a9cf152e8f10db2b661a031adbb2a29db4b075773c2495846d4c926c
 SIZE (openresty-rds-csv-nginx-module-6a90686_GH0.tar.gz) = 20631
 SHA256 (openresty-rds-json-nginx-module-e6517b9_GH0.tar.gz) = 93dc271ff64d9dcbd48e494b72ac7af7a169c58ce4d4a98d732fb71b07e6bf1c
 SIZE (openresty-rds-json-nginx-module-e6517b9_GH0.tar.gz) = 35794
-SHA256 (openresty-redis2-nginx-module-454c223_GH0.tar.gz) = dd27c5c1766d67518c42f51c11ca2f74b2db8a71946f90b4fadf5d868fbede65
-SIZE (openresty-redis2-nginx-module-454c223_GH0.tar.gz) = 25731
 SHA256 (arut-nginx-rtmp-module-6c7719d_GH0.tar.gz) = af459cb16d276cf76a73adba55bc063330136090f7ce9279b851c35eea8c57da
 SIZE (arut-nginx-rtmp-module-6c7719d_GH0.tar.gz) = 520109
 SHA256 (openresty-set-misc-nginx-module-eb223c9_GH0.tar.gz) = 1eeea5ea1df3531e5a1fafde1464b3bb688a7ef1451875017dc25f72c733244b
 SIZE (openresty-set-misc-nginx-module-eb223c9_GH0.tar.gz) = 30088
-SHA256 (sflow-nginx-sflow-module-f15c87f_GH0.tar.gz) = 251de3a5b588a4721effe88f3dbc632706321b7cd1af5fae7aa4f38ca50d2637
-SIZE (sflow-nginx-sflow-module-f15c87f_GH0.tar.gz) = 29515
 SHA256 (nginx-shib-nginx-http-shibboleth-629ae1f_GH0.tar.gz) = 79d3d8330c58254605e569bb34371c030122ad2f52e0191cbf06df3bc316952c
 SIZE (nginx-shib-nginx-http-shibboleth-629ae1f_GH0.tar.gz) = 23907
 SHA256 (openresty-srcache-nginx-module-bcdcfdc_GH0.tar.gz) = fbe15bc0c2d52f778b04d4433e220f219bde0660d19c6acedf67aa194049b130
diff --git a/www/nginx-devel/files/extra-patch-nginx-gridfs_config b/www/nginx-devel/files/extra-patch-nginx-gridfs_config
deleted file mode 100644
index 730af5a858f9..000000000000
--- a/www/nginx-devel/files/extra-patch-nginx-gridfs_config
+++ /dev/null
@@ -1,14 +0,0 @@
---- ../nginx-gridfs-059bdc3/nginx-gridfs/config.orig	2026-07-07 12:40:20.001344000 +0000
-+++ ../nginx-gridfs-059bdc3/nginx-gridfs/config	2026-07-07 12:41:06.850920000 +0000
-@@ -1,7 +1,7 @@
- ngx_module_type=HTTP
- ngx_module_name=ngx_http_gridfs_module
--ngx_module_incs="/usr/include/libmongoc-1.0 /usr/include/libbson-1.0"
--ngx_module_libs="-lmongoc-1.0 -lbson-1.0"
-+ngx_module_incs=`pkg-config --cflags-only-I mongoc2 bson2 | sed -e 's/-I//g'`
-+ngx_module_libs=`pkg-config --libs mongoc2 bson2`
- ngx_module_srcs="$ngx_addon_dir/ngx_http_gridfs_module.c"
- . auto/module
--ngx_addon_name=$ngx_module_name
-\ No newline at end of file
-+ngx_addon_name=$ngx_module_name
diff --git a/www/nginx-devel/files/extra-patch-nginx-gridfs_ngx_http_gridfs_module.c b/www/nginx-devel/files/extra-patch-nginx-gridfs_ngx_http_gridfs_module.c
deleted file mode 100644
index 2471ad2c99e6..000000000000
--- a/www/nginx-devel/files/extra-patch-nginx-gridfs_ngx_http_gridfs_module.c
+++ /dev/null
@@ -1,21 +0,0 @@
---- ../nginx-gridfs-059bdc3/nginx-gridfs/ngx_http_gridfs_module.c.orig	2018-01-20 07:53:32.000000000 +0000
-+++ ../nginx-gridfs-059bdc3/nginx-gridfs/ngx_http_gridfs_module.c	2026-07-07 14:27:08.501699000 +0000
-@@ -1,7 +1,8 @@
- #include <ngx_config.h>
- #include <ngx_core.h>
- #include <ngx_http.h>
--#include <mongoc.h>
-+#include <mongoc/mongoc.h>
-+#include <assert.h>
- #include <signal.h>
- #include <stdio.h>
- 
-@@ -361,7 +361,7 @@
-     bson_init(&filter);
-     bson_oid_init_from_string(&oid, (const char*)value);
-     bson_append_oid(&filter, "_id", -1, &oid);
--    gfile = mongoc_gridfs_find_one(gridfs, &filter, &error);
-+    gfile = mongoc_gridfs_find_one_with_opts(gridfs, &filter, NULL, &error);
- 
-     bson_destroy (&filter);
- 
diff --git a/www/nginx-devel/files/extra-patch-ngx_http_sflow_config.c b/www/nginx-devel/files/extra-patch-ngx_http_sflow_config.c
deleted file mode 100644
index 85cbb181acc2..000000000000
--- a/www/nginx-devel/files/extra-patch-ngx_http_sflow_config.c
+++ /dev/null
@@ -1,10 +0,0 @@
---- ../nginx-sflow-module-f15c87f/ngx_http_sflow_config.c.orig	2012-06-07 04:52:57.000000000 +0400
-+++ ../nginx-sflow-module-f15c87f/ngx_http_sflow_config.c	2012-06-07 04:59:18.000000000 +0400
-@@ -26,7 +26,6 @@
-         ngx_log_error(NGX_LOG_ERR, log, 0, "getaddrinfo() failed: %s", gai_strerror(err));
-         switch(err) {
-         case EAI_NONAME: break;
--        case EAI_NODATA: break;
-         case EAI_AGAIN: break; // loop and try again?
-         default: ngx_log_error(NGX_LOG_ERR, log, 0, "getaddrinfo() error: %s", gai_strerror(err)); break;
-         }
diff --git a/www/nginx-devel/files/extra-patch-ngx_http_sflow_config.h b/www/nginx-devel/files/extra-patch-ngx_http_sflow_config.h
deleted file mode 100644
index 958e63a77caa..000000000000
--- a/www/nginx-devel/files/extra-patch-ngx_http_sflow_config.h
+++ /dev/null
@@ -1,11 +0,0 @@
---- ../nginx-sflow-module-f15c87f/ngx_http_sflow_config.h.orig	2012-07-31 21:36:49.000000000 +0400
-+++ ../nginx-sflow-module-f15c87f/ngx_http_sflow_config.h	2012-07-31 21:37:20.000000000 +0400
-@@ -17,7 +17,7 @@
-   -----------------___________________________------------------
- */
- 
--#define SFWB_DEFAULT_CONFIGFILE "/etc/hsflowd.auto"
-+#define SFWB_DEFAULT_CONFIGFILE "%%PREFIX%%/etc/hsflowd.auto"
- #define SFWB_SEPARATORS " \t\r\n="
- #define SFWB_QUOTES "'\" \t\r\n"
- /* SFWB_MAX LINE LEN must be enough to hold the whole list of targets */
diff --git a/www/nginx-devel/files/extra-patch-ngx_http_sflow_module.c b/www/nginx-devel/files/extra-patch-ngx_http_sflow_module.c
deleted file mode 100644
index aaf343139719..000000000000
--- a/www/nginx-devel/files/extra-patch-ngx_http_sflow_module.c
+++ /dev/null
@@ -1,56 +0,0 @@
---- ../nginx-sflow-module-f15c87f/ngx_http_sflow_module.c.orig	2017-10-16 17:39:14.000000000 -0400
-+++ ../nginx-sflow-module-f15c87f/ngx_http_sflow_module.c	2025-02-04 16:15:53.466117000 -0500
-@@ -8,9 +8,6 @@
- #include <ngx_http.h>
- #include <nginx.h>
- 
--#if (NGX_THREADS)
--#include <ngx_thread.h>
--#endif
- 
- #include "ngx_http_sflow_api.h"
- #include "ngx_http_sflow_config.h"
-@@ -74,18 +71,10 @@
-     /* keep log ptr for callbacks */
-     ngx_log_t *log;
- 
--#if (NGX_THREADS)
--    ngx_thread_mutex_t *mut;
--#define SFWB_LOCK(_s) ngx_thread_mutex_lock((_s)->mut, (_s)->log)
--#define SFWB_UNLOCK(_s) ngx_thread_mutex_unlock((_s)->mut, (_s)->log)
--#define SFWB_INC_CTR(_c) ngx_atomic_fetch_add(&(_c), 1)
--#define SFWB_COUNTDOWN(_c) (ngx_atomic_fetch_add(&(_c), -1) == 1)
--#else
- #define SFWB_LOCK(_s) /* no-op */
- #define SFWB_UNLOCK(_s) /* no-op */
- #define SFWB_INC_CTR(_c) (_c)++
- #define SFWB_COUNTDOWN(_c) (--(_c) == 0)
--#endif
- 
-     /* skip countdown is handled per-worker to reduce lock contention.
-      * If all processes sample at 1:N it's the same as having only one
-@@ -645,10 +634,6 @@
- {
-     sm->random_seed  = ((sm->random_seed * 32719) + 3) % 32749;
-     ngx_atomic_t next_skip = (sm->random_seed % ((2 * sm->sampling_rate) - 1)) + 1;
--#if (NGX_THREADS)
--    ngx_atomic_int_t test_skip = ngx_atomic_fetch_add(&sm->sflow_skip, next_skip);
--    return (test_skip + next_skip);
--#else
-     sm->sflow_skip = next_skip;
-     return next_skip;
- #endif
-@@ -864,13 +849,6 @@
- {
-     ngx_log_debug0(NGX_LOG_DEBUG_HTTP, cf->log, 0, "sflow: sfwb_init()");
- 
--#if (NGX_THREADS)
--    /* a mutex to lock the sFlow agent when taking a sample (only needed if there
--     * is more that one worker thread - right now it seems like threads are not even
--     * an option in the configure script)
--     */
--    ngx_thread_mutex_create(sm->mut, cf->log);
--#endif
- 
-     /* look up some vars by name and cache the index numbers -- see ngx_http_variables.c */
-     ngx_str_t str_uri = ngx_string("request_uri"); /* the "unparsed" variant */
diff --git a/www/nginx-devel/files/extra-patch-ngx_postgres-config b/www/nginx-devel/files/extra-patch-ngx_postgres-config
deleted file mode 100644
index 8c26c0f7dd64..000000000000
--- a/www/nginx-devel/files/extra-patch-ngx_postgres-config
+++ /dev/null
@@ -1,19 +0,0 @@
---- ../ngx_postgres-8aa7359/config.orig	2015-05-26 20:52:25.649166000 +0300
-+++ ../ngx_postgres-8aa7359/config	2015-05-26 20:53:10.331122000 +0300
-@@ -48,12 +48,12 @@
- 
-     if [ $ngx_found = no ]; then
-         # FreeBSD
--        ngx_feature="libpq library in /usr/local/"
--        ngx_feature_path="/usr/local/include"
-+        ngx_feature="libpq library in %%PREFIX%%/"
-+        ngx_feature_path="%%PREFIX%%/include"
-         if [ $NGX_RPATH = YES ]; then
--            ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lpq"
-+            ngx_feature_libs="-R%%PREFIX%%/lib -L%%PREFIX%%/lib -lpq"
-         else
--            ngx_feature_libs="-L/usr/local/lib -lpq"
-+            ngx_feature_libs="-L%%PREFIX%%/lib -lpq"
-         fi
-         . auto/feature
-     fi
diff --git a/www/nginx-devel/pkg-plist b/www/nginx-devel/pkg-plist
index 262046e775dd..aa644423d752 100644
--- a/www/nginx-devel/pkg-plist
+++ b/www/nginx-devel/pkg-plist
@@ -72,6 +72,7 @@
 %%DSO%%%%REDIS2%%libexec/nginx/ngx_http_redis2_module.so
 %%DSO%%%%RTMP%%libexec/nginx/ngx_rtmp_module.so
 %%DSO%%%%SET_MISC%%libexec/nginx/ngx_http_set_misc_module.so
+%%DSO%%%%SFLOW%%libexec/nginx/ngx_http_sflow_module.so
 %%DSO%%%%SHIBBOLETH%%libexec/nginx/ngx_http_shibboleth_module.so
 %%DSO%%%%SLOWFS_CACHE%%libexec/nginx/ngx_http_slowfs_module.so
 %%DSO%%%%SRCACHE%%libexec/nginx/ngx_http_srcache_filter_module.so
diff --git a/www/nginx/Makefile b/www/nginx/Makefile
index c99192be2907..90a4545ceda7 100644
--- a/www/nginx/Makefile
+++ b/www/nginx/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	nginx
 PORTVERSION=	${NGINX_VERSION}
 .include "version.mk"
-PORTREVISION=	4
+PORTREVISION=	5
 PORTEPOCH=	3
 CATEGORIES=	www
 MASTER_SITES=	https://nginx.org/download/ \
@@ -335,14 +335,6 @@ post-patch-PASSENGER-on:
 		s!-Iext/libeio!!' \
 		${WRKSRC_PASSENGER}/build/common_library.rb
 
-post-patch-POSTGRES-on:
-	@${REINPLACE_CMD} 's!%%PREFIX%%!${LOCALBASE}!g' ${WRKSRC_postgres}/config
-
-post-patch-SFLOW-on:
-	@${REINPLACE_CMD} \
-		's!%%PREFIX%%!${LOCALBASE}!g' \
-		${WRKSRC_sflow}/ngx_http_sflow_config.h
-
 pre-configure-SMALL_LIGHT-on:
 	( cd ${WRKSRC_small_light} && ./setup )
 
@@ -371,6 +363,11 @@ pre-configure-FORMINPUT-on:
 	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-form-input ${WRKSRC_forminput}
 	@${CHMOD} -R u+w ${WRKSRC_forminput}
 
+pre-configure-GRIDFS-on:
+	@${RM} -rf ${WRKSRC_gridfs}
+	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-gridfs ${WRKSRC_gridfs}
+	@${CHMOD} -R u+w ${WRKSRC_gridfs}
+
 pre-configure-LET-on:
 	@${RM} -rf ${WRKSRC_let}
 	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-let ${WRKSRC_let}
@@ -392,6 +389,23 @@ pre-configure-NJS-on:
 	@${CHMOD} -R u+w ${WRKSRC_njs}
 	@${CHMOD} u+x ${WRKSRC_njs}/configure
 
+pre-configure-POSTGRES-on:
+	@${RM} -rf ${WRKSRC_postgres}
+	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-postgres ${WRKSRC_postgres}
+	@${CHMOD} -R u+w ${WRKSRC_postgres}
+
+pre-configure-REDIS2-on:
+	@${RM} -rf ${WRKSRC_redis2}
+	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-redis2 ${WRKSRC_redis2}
+	@${CHMOD} -R u+w ${WRKSRC_redis2}
+
+pre-configure-SFLOW-on:
+	@${RM} -rf ${WRKSRC_sflow}
+	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-sflow ${WRKSRC_sflow}
+	@${CHMOD} -R u+w ${WRKSRC_sflow}
+	@${REINPLACE_CMD} 's!"/etc/hsflowd.auto"!"${LOCALBASE}/etc/hsflowd.auto"!' \
+		${WRKSRC_sflow}/src/ngx_http_sflow_config.h
+
 pre-configure-SLOWFS_CACHE-on:
 	@${RM} -rf ${WRKSRC_slowfs_cache}
 	@${CP} -R ${LOCALBASE}/share/nginx/modules/nginx-module-slowfs-cache ${WRKSRC_slowfs_cache}
diff --git a/www/nginx/Makefile.extmod b/www/nginx/Makefile.extmod
index e77a3b96b8b2..8e48694e73ea 100644
--- a/www/nginx/Makefile.extmod
+++ b/www/nginx/Makefile.extmod
@@ -66,13 +66,12 @@ FORMINPUT_BUILD_DEPENDS=	nginx-module-form-input>0:www/nginx-module-form-input
 WRKSRC_forminput=	${WRKDIR}/nginx-form-input-module
 FORMINPUT_VARS=		DSO_EXTMODS+=forminput
 
-GRIDFS_GH_TUPLE=	nieoding:nginx-gridfs:059bdc3:gridfs
 GRIDFS_LIB_DEPENDS=	libbson2.so:devel/libbson \
 			libmongoc2.so:devel/mongo-c-driver
 GRIDFS_USES=		pkgconfig
-GRIDFS_VARS=		DSO_EXTMODS+=gridfs GRIDFS_SUBDIR=/nginx-gridfs
-GRIDFS_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-nginx-gridfs_ngx_http_gridfs_module.c \
-			${PATCHDIR}/extra-patch-nginx-gridfs_config
+GRIDFS_BUILD_DEPENDS=	nginx-module-gridfs>0:www/nginx-module-gridfs
+WRKSRC_gridfs=		${WRKDIR}/nginx-gridfs-module
+GRIDFS_VARS=		DSO_EXTMODS+=gridfs
 
 HEADERS_MORE_GH_TUPLE=		openresty:headers-more-nginx-module:06dc0be:headers_more
 HEADERS_MORE_VARS=		DSO_EXTMODS+=headers_more
@@ -288,8 +287,8 @@ PASSENGER_VARS=		WRKSRC_passenger=${WRKDIR}/passenger-${PASSENGER_NGINX_VER} \
 			DSO_EXTDIRS+=passenger-${PASSENGER_NGINX_VER}/src/nginx_module
 
 POSTGRES_USES=		pgsql
-POSTGRES_GH_TUPLE=	konstruxi:ngx_postgres:8aa7359:postgres
-POSTGRES_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-ngx_postgres-config
+POSTGRES_BUILD_DEPENDS=	nginx-module-postgres>0:www/nginx-module-postgres
+WRKSRC_postgres=	${WRKDIR}/nginx-postgres-module
 POSTGRES_VARS=		DSO_EXTMODS+=postgres
 
 RDS_CSV_GH_TUPLE=	openresty:rds-csv-nginx-module:v0.09:rdscsv
@@ -300,7 +299,8 @@ RDS_JSON_GH_TUPLE=	openresty:rds-json-nginx-module:v0.15:rdsjson
 RDS_JSON_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-rds-json-nginx-module-config
 RDS_JSON_VARS=		DSO_EXTMODS+=rdsjson
 
-REDIS2_GH_TUPLE=	openresty:redis2-nginx-module:v0.15:redis2
+REDIS2_BUILD_DEPENDS=	nginx-module-redis2>0:www/nginx-module-redis2
+WRKSRC_redis2=		${WRKDIR}/nginx-redis2-module
 REDIS2_VARS=		DSO_EXTMODS+=redis2
 
 RTMP_GH_TUPLE=		arut:nginx-rtmp-module:v1.2.2:rtmp
@@ -310,10 +310,9 @@ SET_MISC_IMPLIES=	DEVEL_KIT
 SET_MISC_GH_TUPLE=	openresty:set-misc-nginx-module:3937e7b:setmisc
 SET_MISC_VARS=		DSO_EXTMODS+=setmisc
 
-SFLOW_GH_TUPLE=		sflow:nginx-sflow-module:543c72a:sflow
-SFLOW_EXTRA_PATCHES=	${PATCHDIR}/extra-patch-ngx_http_sflow_config.c \
-			${PATCHDIR}/extra-patch-ngx_http_sflow_config.h \
-			${PATCHDIR}/extra-patch-ngx_http_sflow_module.c
+SFLOW_BUILD_DEPENDS=	nginx-module-sflow>0:www/nginx-module-sflow
+WRKSRC_sflow=		${WRKDIR}/nginx-sflow-module
+SFLOW_VARS=		DSO_EXTMODS+=sflow
 
 SHIBBOLETH_GH_TUPLE=	nginx-shib:nginx-http-shibboleth:be12df5:shibboleth
 SHIBBOLETH_VARS=	DSO_EXTMODS+=shibboleth
diff --git a/www/nginx/distinfo b/www/nginx/distinfo
index db6476ef4ce2..18cd7d3b344b 100644
--- a/www/nginx/distinfo
+++ b/www/nginx/distinfo
@@ -21,8 +21,6 @@ SHA256 (openresty-encrypted-session-nginx-module-v0.09_GH0.tar.gz) = fe9b95acf97
 SIZE (openresty-encrypted-session-nginx-module-v0.09_GH0.tar.gz) = 11847
 SHA256 (ogarrett-nginx-fips-check-module-6cb4270_GH0.tar.gz) = d52fbb0f2819cd91b710ad85e6c8b452fdca6a5d81b0694d6637adba3fc2382c
 SIZE (ogarrett-nginx-fips-check-module-6cb4270_GH0.tar.gz) = 6494
-SHA256 (nieoding-nginx-gridfs-059bdc3_GH0.tar.gz) = 9b059b5ae7b602d12d32d5ebe2700827ea625f22c0fb3b9956242e11de63845b
-SIZE (nieoding-nginx-gridfs-059bdc3_GH0.tar.gz) = 4674
 SHA256 (openresty-headers-more-nginx-module-06dc0be_GH0.tar.gz) = 883b1e31d59f3eb1e76b34259711ad65a3443102973dcf22df329397f3d5eaa4
 SIZE (openresty-headers-more-nginx-module-06dc0be_GH0.tar.gz) = 29438
 SHA256 (dvershinin-nginx_accept_language_module-5683967_GH0.tar.gz) = a58feb576f2231498b8a3863d3c6fba45c7d48bc48735fa714e07a7bfbedb6e3
@@ -89,20 +87,14 @@ SHA256 (libinjection-libinjection-4aa3894_GH0.tar.gz) = ededea133e89e238ef2e60d0
 SIZE (libinjection-libinjection-4aa3894_GH0.tar.gz) = 2218294
 SHA256 (osokin-nginx-otel-51273ec_GH0.tar.gz) = a2107ba0be94c8561ae50773163c7946a58e508be46920f588d05a347c867d9c
 SIZE (osokin-nginx-otel-51273ec_GH0.tar.gz) = 28076
-SHA256 (konstruxi-ngx_postgres-8aa7359_GH0.tar.gz) = c69ad4495de7c7883ebc23e1e6c4cc83a4ac6a7fddd4d5c12e49d33b65f7c50b
-SIZE (konstruxi-ngx_postgres-8aa7359_GH0.tar.gz) = 48544
 SHA256 (openresty-rds-csv-nginx-module-v0.09_GH0.tar.gz) = 896be99c0cad50218417800a159e43ec088d6b58c099472ed3b3d7f179d6c0ea
 SIZE (openresty-rds-csv-nginx-module-v0.09_GH0.tar.gz) = 20531
 SHA256 (openresty-rds-json-nginx-module-v0.15_GH0.tar.gz) = eaf18f60e981ea2442a7902689a26eba6cf6f36ebee712feeb1f4429eb654bdc
 SIZE (openresty-rds-json-nginx-module-v0.15_GH0.tar.gz) = 34744
-SHA256 (openresty-redis2-nginx-module-v0.15_GH0.tar.gz) = d255571bcfb9939b78099df39cb4d42f174d789aec8c8e5e47b93942b0299438
-SIZE (openresty-redis2-nginx-module-v0.15_GH0.tar.gz) = 25471
 SHA256 (arut-nginx-rtmp-module-v1.2.2_GH0.tar.gz) = 07f19b7bffec5e357bb8820c63e5281debd45f5a2e6d46b1636d9202c3e09d78
 SIZE (arut-nginx-rtmp-module-v1.2.2_GH0.tar.gz) = 519934
 SHA256 (openresty-set-misc-nginx-module-3937e7b_GH0.tar.gz) = cb3a4675ab6b8741e5847cf5bc41ee3f6ec5cbceec53188f9ae96e48feea17c5
 SIZE (openresty-set-misc-nginx-module-3937e7b_GH0.tar.gz) = 29335
-SHA256 (sflow-nginx-sflow-module-543c72a_GH0.tar.gz) = 95efdb1f6cfd6c32c577707f693eb6795c6f21ae062842bf84fe762d8b842955
-SIZE (sflow-nginx-sflow-module-543c72a_GH0.tar.gz) = 29504
 SHA256 (nginx-shib-nginx-http-shibboleth-be12df5_GH0.tar.gz) = aff9830b5de78dd9ce32cd2c55c5cf9173c99fe1a1d2190407c96668e7517bab
 SIZE (nginx-shib-nginx-http-shibboleth-be12df5_GH0.tar.gz) = 23872
 SHA256 (openresty-srcache-nginx-module-be22ac0_GH0.tar.gz) = 5753d1ffe87b5d6f5b7a0696667bb5ff1388738136fdee26ba55bc33f5796061
diff --git a/www/nginx/files/extra-patch-nginx-gridfs_config b/www/nginx/files/extra-patch-nginx-gridfs_config
deleted file mode 100644
index 730af5a858f9..000000000000
--- a/www/nginx/files/extra-patch-nginx-gridfs_config
+++ /dev/null
@@ -1,14 +0,0 @@
---- ../nginx-gridfs-059bdc3/nginx-gridfs/config.orig	2026-07-07 12:40:20.001344000 +0000
-+++ ../nginx-gridfs-059bdc3/nginx-gridfs/config	2026-07-07 12:41:06.850920000 +0000
-@@ -1,7 +1,7 @@
- ngx_module_type=HTTP
- ngx_module_name=ngx_http_gridfs_module
--ngx_module_incs="/usr/include/libmongoc-1.0 /usr/include/libbson-1.0"
--ngx_module_libs="-lmongoc-1.0 -lbson-1.0"
-+ngx_module_incs=`pkg-config --cflags-only-I mongoc2 bson2 | sed -e 's/-I//g'`
-+ngx_module_libs=`pkg-config --libs mongoc2 bson2`
- ngx_module_srcs="$ngx_addon_dir/ngx_http_gridfs_module.c"
- . auto/module
--ngx_addon_name=$ngx_module_name
-\ No newline at end of file
-+ngx_addon_name=$ngx_module_name
diff --git a/www/nginx/files/extra-patch-nginx-gridfs_ngx_http_gridfs_module.c b/www/nginx/files/extra-patch-nginx-gridfs_ngx_http_gridfs_module.c
deleted file mode 100644
index 2471ad2c99e6..000000000000
--- a/www/nginx/files/extra-patch-nginx-gridfs_ngx_http_gridfs_module.c
+++ /dev/null
@@ -1,21 +0,0 @@
---- ../nginx-gridfs-059bdc3/nginx-gridfs/ngx_http_gridfs_module.c.orig	2018-01-20 07:53:32.000000000 +0000
-+++ ../nginx-gridfs-059bdc3/nginx-gridfs/ngx_http_gridfs_module.c	2026-07-07 14:27:08.501699000 +0000
-@@ -1,7 +1,8 @@
- #include <ngx_config.h>
- #include <ngx_core.h>
- #include <ngx_http.h>
--#include <mongoc.h>
-+#include <mongoc/mongoc.h>
-+#include <assert.h>
- #include <signal.h>
- #include <stdio.h>
- 
-@@ -361,7 +361,7 @@
-     bson_init(&filter);
-     bson_oid_init_from_string(&oid, (const char*)value);
-     bson_append_oid(&filter, "_id", -1, &oid);
--    gfile = mongoc_gridfs_find_one(gridfs, &filter, &error);
-+    gfile = mongoc_gridfs_find_one_with_opts(gridfs, &filter, NULL, &error);
- 
-     bson_destroy (&filter);
- 
diff --git a/www/nginx/files/extra-patch-ngx_http_sflow_config.c b/www/nginx/files/extra-patch-ngx_http_sflow_config.c
deleted file mode 100644
index 3e3eaa2260f5..000000000000
--- a/www/nginx/files/extra-patch-ngx_http_sflow_config.c
+++ /dev/null
@@ -1,10 +0,0 @@
---- ../nginx-sflow-module-543c72a/ngx_http_sflow_config.c.orig	2012-06-07 04:52:57.000000000 +0400
-+++ ../nginx-sflow-module-543c72a/ngx_http_sflow_config.c	2012-06-07 04:59:18.000000000 +0400
-@@ -26,7 +26,6 @@
-         ngx_log_error(NGX_LOG_ERR, log, 0, "getaddrinfo() failed: %s", gai_strerror(err));
-         switch(err) {
-         case EAI_NONAME: break;
--        case EAI_NODATA: break;
-         case EAI_AGAIN: break; // loop and try again?
-         default: ngx_log_error(NGX_LOG_ERR, log, 0, "getaddrinfo() error: %s", gai_strerror(err)); break;
-         }
diff --git a/www/nginx/files/extra-patch-ngx_http_sflow_config.h b/www/nginx/files/extra-patch-ngx_http_sflow_config.h
deleted file mode 100644
index 6b90d4eaaf14..000000000000
--- a/www/nginx/files/extra-patch-ngx_http_sflow_config.h
+++ /dev/null
@@ -1,11 +0,0 @@
---- ../nginx-sflow-module-543c72a/ngx_http_sflow_config.h.orig	2012-07-31 21:36:49.000000000 +0400
-+++ ../nginx-sflow-module-543c72a/ngx_http_sflow_config.h	2012-07-31 21:37:20.000000000 +0400
-@@ -17,7 +17,7 @@
-   -----------------___________________________------------------
- */
- 
--#define SFWB_DEFAULT_CONFIGFILE "/etc/hsflowd.auto"
-+#define SFWB_DEFAULT_CONFIGFILE "%%PREFIX%%/etc/hsflowd.auto"
- #define SFWB_SEPARATORS " \t\r\n="
- #define SFWB_QUOTES "'\" \t\r\n"
- /* SFWB_MAX LINE LEN must be enough to hold the whole list of targets */
diff --git a/www/nginx/files/extra-patch-ngx_http_sflow_module.c b/www/nginx/files/extra-patch-ngx_http_sflow_module.c
deleted file mode 100644
index e6b4bad6e25f..000000000000
--- a/www/nginx/files/extra-patch-ngx_http_sflow_module.c
+++ /dev/null
@@ -1,59 +0,0 @@
---- ../nginx-sflow-module-543c72a/ngx_http_sflow_module.c.orig	2014-09-24 18:20:41.000000000 -0400
-+++ ../nginx-sflow-module-543c72a/ngx_http_sflow_module.c	2016-08-06 21:26:24.515559000 -0400
-@@ -8,9 +8,6 @@
- #include <ngx_http.h>
- #include <nginx.h>
- 
--#if (NGX_THREADS)
--#include <ngx_thread.h>
--#endif
- 
- #include "ngx_http_sflow_api.h"
- #include "ngx_http_sflow_config.h"
-@@ -74,18 +71,10 @@
-     /* keep log ptr for callbacks */
-     ngx_log_t *log;
- 
--#if (NGX_THREADS)
--    ngx_mutex_t *mut;
--#define SFWB_LOCK(_s) ngx_mutex_lock((_s)->mut)
--#define SFWB_UNLOCK(_s) ngx_mutex_unlock((_s)->mut)
--#define SFWB_INC_CTR(_c) ngx_atomic_fetch_add(&(_c), 1)
--#define SFWB_COUNTDOWN(_c) (ngx_atomic_fetch_add(&(_c), -1) == 1)
--#else
- #define SFWB_LOCK(_s) /* no-op */
- #define SFWB_UNLOCK(_s) /* no-op */
- #define SFWB_INC_CTR(_c) (_c)++
- #define SFWB_COUNTDOWN(_c) (--(_c) == 0)
--#endif
- 
*** 67 LINES SKIPPED ***