]> git.kaiwu.me - nginx.git/commitdiff
Merge of r4698: X-Forwarded-For conditionals.
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 2 Jul 2012 17:41:52 +0000 (17:41 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 2 Jul 2012 17:41:52 +0000 (17:41 +0000)
Fixed compile-time conditionals used to detect if X-Forwarded-For support
is needed.

Note: compatibility shims were added during merge to avoid possible
breakage of 3rd party modules.  At least cache purge module was broken
by the original commit, as it used to rely on NGX_HTTP_PROXY define.

auto/modules
src/http/ngx_http_request.c
src/http/ngx_http_request.h
src/http/ngx_http_variables.c

index ebea302325d6248e7230f083f4b80739f3c5bcb1..d872c4e392c9f9f9d4b913651b5be6ab7486dcf9 100644 (file)
@@ -223,6 +223,7 @@ fi
 
 if [ $HTTP_REALIP = YES ]; then
     have=NGX_HTTP_REALIP . auto/have
+    have=NGX_HTTP_X_FORWARDED_FOR . auto/have
     HTTP_MODULES="$HTTP_MODULES $HTTP_REALIP_MODULE"
     HTTP_SRCS="$HTTP_SRCS $HTTP_REALIP_SRCS"
 fi
@@ -234,11 +235,13 @@ fi
 
 if [ $HTTP_GEO = YES ]; then
     have=NGX_HTTP_GEO . auto/have
+    have=NGX_HTTP_X_FORWARDED_FOR . auto/have
     HTTP_MODULES="$HTTP_MODULES $HTTP_GEO_MODULE"
     HTTP_SRCS="$HTTP_SRCS $HTTP_GEO_SRCS"
 fi
 
 if [ $HTTP_GEOIP = YES ]; then
+    have=NGX_HTTP_X_FORWARDED_FOR . auto/have
     HTTP_MODULES="$HTTP_MODULES $HTTP_GEOIP_MODULE"
     HTTP_SRCS="$HTTP_SRCS $HTTP_GEOIP_SRCS"
 fi
@@ -274,6 +277,7 @@ fi
 
 if [ $HTTP_PROXY = YES ]; then
     have=NGX_HTTP_PROXY . auto/have
+    have=NGX_HTTP_X_FORWARDED_FOR . auto/have
     #USE_MD5=YES
     HTTP_MODULES="$HTTP_MODULES $HTTP_PROXY_MODULE"
     HTTP_DEPS="$HTTP_DEPS $HTTP_PROXY_DEPS"
index b1877131cc979bacb7ac21c3d006f98ca6db2752..e0ae5241f4ed71fa0005bfd1a93ffbd8233710dc 100644 (file)
@@ -138,7 +138,7 @@ ngx_http_header_t  ngx_http_headers_in[] = {
     { ngx_string("Keep-Alive"), offsetof(ngx_http_headers_in_t, keep_alive),
                  ngx_http_process_header_line },
 
-#if (NGX_HTTP_PROXY || NGX_HTTP_REALIP || NGX_HTTP_GEO)
+#if (NGX_HTTP_X_FORWARDED_FOR)
     { ngx_string("X-Forwarded-For"),
                  offsetof(ngx_http_headers_in_t, x_forwarded_for),
                  ngx_http_process_header_line },
index 70ca6097efa89728af964f1d0109700fb9a2109f..c2651a86fd1a07ba5c6eb6ae88a422b72b4b907f 100644 (file)
 #define NGX_HTTP_COPY_BUFFERED             0x04
 
 
+#if (NGX_HTTP_PROXY || NGX_HTTP_REALIP || NGX_HTTP_GEO)
+#ifndef NGX_HTTP_X_FORWARDED_FOR
+#define NGX_HTTP_X_FORWARDED_FOR           1
+#endif
+#endif
+
+
 typedef enum {
     NGX_HTTP_INITING_REQUEST_STATE = 0,
     NGX_HTTP_READING_REQUEST_STATE,
@@ -192,7 +199,7 @@ typedef struct {
 
     ngx_table_elt_t                  *keep_alive;
 
-#if (NGX_HTTP_PROXY || NGX_HTTP_REALIP || NGX_HTTP_GEO)
+#if (NGX_HTTP_X_FORWARDED_FOR)
     ngx_table_elt_t                  *x_forwarded_for;
 #endif
 
index 76b292553be4e3ab0986f6a6951ba2bafe647b13..f34a6d9a37293ff0c6be4095229f42e308726177 100644 (file)
@@ -134,7 +134,7 @@ static ngx_http_variable_t  ngx_http_core_variables[] = {
       offsetof(ngx_http_request_t, headers_in.via), 0, 0 },
 #endif
 
-#if (NGX_HTTP_PROXY || NGX_HTTP_REALIP)
+#if (NGX_HTTP_X_FORWARDED_FOR)
     { ngx_string("http_x_forwarded_for"), NULL, ngx_http_variable_header,
       offsetof(ngx_http_request_t, headers_in.x_forwarded_for), 0, 0 },
 #endif