aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_realip_module.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2014-03-17 17:41:24 +0400
committerRoman Arutyunyan <arut@nginx.com>2014-03-17 17:41:24 +0400
commit0b5f3297849c6061cf07b359e8b42768889e28cd (patch)
tree5ae00cb3fd666a763e76baef6598a2edc577734e /src/http/modules/ngx_http_realip_module.c
parent2f917b6d0636bd62ab0dfce0cad28148b0e9b002 (diff)
downloadnginx-0b5f3297849c6061cf07b359e8b42768889e28cd.tar.gz
nginx-0b5f3297849c6061cf07b359e8b42768889e28cd.zip
Added server-side support for PROXY protocol v1 (ticket #355).
Client address specified in the PROXY protocol header is now saved in the $proxy_protocol_addr variable and can be used in the realip module. This is currently not implemented for mail.
Diffstat (limited to 'src/http/modules/ngx_http_realip_module.c')
-rw-r--r--src/http/modules/ngx_http_realip_module.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/http/modules/ngx_http_realip_module.c b/src/http/modules/ngx_http_realip_module.c
index b15954759..7a6211803 100644
--- a/src/http/modules/ngx_http_realip_module.c
+++ b/src/http/modules/ngx_http_realip_module.c
@@ -13,6 +13,7 @@
#define NGX_HTTP_REALIP_XREALIP 0
#define NGX_HTTP_REALIP_XFWD 1
#define NGX_HTTP_REALIP_HEADER 2
+#define NGX_HTTP_REALIP_PROXY 3
typedef struct {
@@ -156,6 +157,18 @@ ngx_http_realip_handler(ngx_http_request_t *r)
break;
+ case NGX_HTTP_REALIP_PROXY:
+
+ value = &r->connection->proxy_protocol_addr;
+
+ if (value->len == 0) {
+ return NGX_DECLINED;
+ }
+
+ xfwd = NULL;
+
+ break;
+
default: /* NGX_HTTP_REALIP_HEADER */
part = &r->headers_in.headers.part;
@@ -343,6 +356,11 @@ ngx_http_realip(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
return NGX_CONF_OK;
}
+ if (ngx_strcmp(value[1].data, "proxy_protocol") == 0) {
+ rlcf->type = NGX_HTTP_REALIP_PROXY;
+ return NGX_CONF_OK;
+ }
+
rlcf->type = NGX_HTTP_REALIP_HEADER;
rlcf->hash = ngx_hash_strlow(value[1].data, value[1].data, value[1].len);
rlcf->header = value[1];