Skip to content

Commit

Permalink
Multihomed machines will report the client IP of the matching SERVER_…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
msaladna committed Dec 30, 2023
1 parent 9c6ef2b commit c33638a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
20 changes: 20 additions & 0 deletions 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;
1 change: 1 addition & 0 deletions 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

<IfDefine !BYPASS_HTTP10>
Expand Down
4 changes: 3 additions & 1 deletion SPECS/httpd.spec
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c33638a

Please sign in to comment.