From 301815e10c93e99ce71bb19e8b6ad326617c30aa Mon Sep 17 00:00:00 2001 From: Eric Covener Date: Sat, 1 Feb 2014 14:02:29 +0000 Subject: [PATCH] Add %{CONN_REMOTE_ADDR} to mod_rewrite. PR56094 Submitted By: Edward Lu Committed By: covener git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1563418 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ docs/manual/mod/mod_rewrite.xml | 9 +++++++++ modules/mappers/mod_rewrite.c | 5 ++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 8c2c47c0443..fb2d96c99d0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_rewrite: Add %{CONN_REMOTE_ADDR} as the non-useragent counterpart to + %{REMOTE_ADDR}. PR 56094. [Edward Lu ] + *) mod_dir: Default to 2.2-like behavior and skip execution when method is neither GET nor POST, such as for DAV requests. PR 54914. [Chris Darroch] diff --git a/docs/manual/mod/mod_rewrite.xml b/docs/manual/mod/mod_rewrite.xml index d0aa4a3ca65..cae83da1d84 100644 --- a/docs/manual/mod/mod_rewrite.xml +++ b/docs/manual/mod/mod_rewrite.xml @@ -443,6 +443,7 @@ Alias /myapp /opt/myapp-1.2.3 REMOTE_ADDR
+ CONN_REMOTE_ADDR
REMOTE_HOST
REMOTE_PORT
REMOTE_USER
@@ -571,6 +572,14 @@ Alias /myapp /opt/myapp-1.2.3 "http" or "https"). This value can be influenced with ServerName. +
REMOTE_ADDR
+
The IP address of the remote host (see the + mod_remoteip module).
+ +
CONN_REMOTE_ADDR
+
Since 2.4.8: The peer IP address of the connection (see the + mod_remoteip module).
+ diff --git a/modules/mappers/mod_rewrite.c b/modules/mappers/mod_rewrite.c index d736187715e..17e6f22aca5 100644 --- a/modules/mappers/mod_rewrite.c +++ b/modules/mappers/mod_rewrite.c @@ -2143,7 +2143,10 @@ static char *lookup_variable(char *var, rewrite_ctx *ctx) break; case 16: - if (!strcmp(var, "REQUEST_FILENAME")) { + if (*var == 'C' && !strcmp(var, "CONN_REMOTE_ADDR")) { + result = r->connection->client_ip; + } + else if (!strcmp(var, "REQUEST_FILENAME")) { result = r->filename; /* same as script_filename (15) */ } break; -- 2.47.3