From 7d79ef3ded993abb2d904f95251b6c4c74336e6d Mon Sep 17 00:00:00 2001 From: Ken Coar Date: Tue, 12 Nov 2002 18:30:00 +0000 Subject: [PATCH] Add a SERVER_ADDR keyword to match the CGI environment variable, to allow conditional setting according to the IP address on which the server received the request. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@97494 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 4 ++++ modules/metadata/mod_setenvif.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 36284ddfee..eadedeba83 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,9 @@ Changes with Apache 2.0.44 + *) mod_setenvif: Add SERVER_ADDR special keyword to allow + envariable setting according to the server IP address + which received the request. [Ken Coar] + *) mod_cgid: Terminate CGI scripts when the client connection drops. PR 8388 [Jeff Trawick] diff --git a/modules/metadata/mod_setenvif.c b/modules/metadata/mod_setenvif.c index ee36cb11e6..0ec8171534 100644 --- a/modules/metadata/mod_setenvif.c +++ b/modules/metadata/mod_setenvif.c @@ -92,6 +92,8 @@ * * Special values for 'name' are: * + * server_addr IP address of interface on which request arrived + * (analogous to SERVER_ADDR set in ap_add_common_vars()) * remote_host Remote host name (if available) * remote_addr Remote IP address * remote_user Remote authenticated user (if any) @@ -143,7 +145,8 @@ enum special { SPECIAL_REMOTE_USER, SPECIAL_REQUEST_URI, SPECIAL_REQUEST_METHOD, - SPECIAL_REQUEST_PROTOCOL + SPECIAL_REQUEST_PROTOCOL, + SPECIAL_SERVER_ADDR }; typedef struct { char *name; /* header name */ @@ -376,6 +379,9 @@ static const char *add_setenvif_core(cmd_parms *cmd, void *mconfig, else if (!strcasecmp(fname, "request_protocol")) { new->special_type = SPECIAL_REQUEST_PROTOCOL; } + else if (!strcasecmp(fname, "server_addr")) { + new->special_type = SPECIAL_SERVER_ADDR; + } else { new->special_type = SPECIAL_NOT; /* Handle fname as a regular expression. @@ -509,6 +515,9 @@ static int match_headers(request_rec *r) case SPECIAL_REMOTE_ADDR: val = r->connection->remote_ip; break; + case SPECIAL_SERVER_ADDR: + val = r->connection->local_ip; + break; case SPECIAL_REMOTE_HOST: val = ap_get_remote_host(r->connection, r->per_dir_config, REMOTE_NAME, NULL); -- 2.50.1