From c33638ae62e80936c3c06b2d48adbfb2a13af39c Mon Sep 17 00:00:00 2001 From: Matt Saladna Date: Fri, 29 Dec 2023 20:47:39 -0500 Subject: [PATCH] Multihomed machines will report the client IP of the matching SERVER_ADDR defined within vhost during resolution. This can be used, if exported to expr(), as a means to detect local traffic thereby skipping bandwidth logging. --- SOURCES/httpd-2.4.58-server-addr-expr.patch | 20 ++++++++++++++++++++ SOURCES/httpd-apnscp-rewrite-map.conf | 1 + SPECS/httpd.spec | 4 +++- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 SOURCES/httpd-2.4.58-server-addr-expr.patch diff --git a/SOURCES/httpd-2.4.58-server-addr-expr.patch b/SOURCES/httpd-2.4.58-server-addr-expr.patch new file mode 100644 index 0000000..5b9cf70 --- /dev/null +++ b/SOURCES/httpd-2.4.58-server-addr-expr.patch @@ -0,0 +1,20 @@ +diff -Nur httpd-2.4.58-orig/server/util_expr_eval.c httpd-2.4.58/server/util_expr_eval.c +--- httpd-2.4.58-orig/server/util_expr_eval.c 2023-07-17 16:33:05.000000000 -0400 ++++ httpd-2.4.58/server/util_expr_eval.c 2023-12-29 20:36:37.778573905 -0500 +@@ -1352,6 +1352,7 @@ + "REQUEST_STATUS", /* 27 */ + "REMOTE_ADDR", /* 28 */ + "REMOTE_PORT", /* 29 */ ++ "SERVER_ADDR", /* 30 */ + NULL + }; + +@@ -1443,6 +1444,8 @@ + return r->useragent_ip; + case 29: + return apr_psprintf(ctx->p, "%u", ctx->c->client_addr->port); ++ case 30: ++ return r->connection->local_ip; + default: + ap_assert(0); + return NULL; diff --git a/SOURCES/httpd-apnscp-rewrite-map.conf b/SOURCES/httpd-apnscp-rewrite-map.conf index 317d310..2122d10 100644 --- a/SOURCES/httpd-apnscp-rewrite-map.conf +++ b/SOURCES/httpd-apnscp-rewrite-map.conf @@ -1,6 +1,7 @@ # (c) 2018 Apis Networks # Domain rewrite maps SetEnvIfNoCase Host ^(?:www\.)?+([^:]+) DOMAIN=$1 +SetEnvIfExpr "%{SERVER_ADDR} == %{REMOTE_ADDR}" is-local RewriteEngine Off diff --git a/SPECS/httpd.spec b/SPECS/httpd.spec index 7f40f76..d167d1d 100644 --- a/SPECS/httpd.spec +++ b/SPECS/httpd.spec @@ -23,7 +23,7 @@ Summary: Apache HTTP Server Name: httpd Version: 2.4.58 -Release: 1%{?dist} +Release: 2%{?dist} Epoch: %{epoch} URL: http://httpd.apache.org/ Vendor: Apache Software Foundation @@ -45,6 +45,7 @@ Patch2: apxs-apnscp.patch Patch3: httpd-2.4-force-symlinks-owner.patch Patch4: httpd-docroot-vpath.patch Patch5: httpd-2.4-suexec-pam.patch +Patch6: httpd-2.4.58-server-addr-expr.patch License: Apache License, Version 2.0 Group: System Environment/Daemons @@ -162,6 +163,7 @@ Security (TLS) protocols. %patch3 -p1 %patch4 -p1 %patch5 -p1 +%patch6 -p1 sed -i '/^#define PLATFORM/s/Unix/%{vstring}/' os/unix/os.h sed -i 's/@RELEASE@/%{release}/' server/core.c