Latest update - 7591
This commit is contained in:
@@ -180,12 +180,11 @@ ngx_http_realip_handler(ngx_http_request_t *r)
|
||||
|
||||
case NGX_HTTP_REALIP_PROXY:
|
||||
|
||||
value = &r->connection->proxy_protocol_addr;
|
||||
|
||||
if (value->len == 0) {
|
||||
if (r->connection->proxy_protocol == NULL) {
|
||||
return NGX_DECLINED;
|
||||
}
|
||||
|
||||
value = &r->connection->proxy_protocol->src_addr;
|
||||
xfwd = NULL;
|
||||
|
||||
break;
|
||||
@@ -238,7 +237,7 @@ found:
|
||||
!= NGX_DECLINED)
|
||||
{
|
||||
if (rlcf->type == NGX_HTTP_REALIP_PROXY) {
|
||||
ngx_inet_set_port(addr.sockaddr, c->proxy_protocol_port);
|
||||
ngx_inet_set_port(addr.sockaddr, c->proxy_protocol->src_port);
|
||||
}
|
||||
|
||||
return ngx_http_realip_set_addr(r, &addr);
|
||||
|
||||
@@ -199,10 +199,20 @@ static ngx_http_variable_t ngx_http_core_variables[] = {
|
||||
{ ngx_string("remote_port"), NULL, ngx_http_variable_remote_port, 0, 0, 0 },
|
||||
|
||||
{ ngx_string("proxy_protocol_addr"), NULL,
|
||||
ngx_http_variable_proxy_protocol_addr, 0, 0, 0 },
|
||||
ngx_http_variable_proxy_protocol_addr,
|
||||
offsetof(ngx_proxy_protocol_t, src_addr), 0, 0 },
|
||||
|
||||
{ ngx_string("proxy_protocol_port"), NULL,
|
||||
ngx_http_variable_proxy_protocol_port, 0, 0, 0 },
|
||||
ngx_http_variable_proxy_protocol_port,
|
||||
offsetof(ngx_proxy_protocol_t, src_port), 0, 0 },
|
||||
|
||||
{ ngx_string("proxy_protocol_server_addr"), NULL,
|
||||
ngx_http_variable_proxy_protocol_addr,
|
||||
offsetof(ngx_proxy_protocol_t, dst_addr), 0, 0 },
|
||||
|
||||
{ ngx_string("proxy_protocol_server_port"), NULL,
|
||||
ngx_http_variable_proxy_protocol_port,
|
||||
offsetof(ngx_proxy_protocol_t, dst_port), 0, 0 },
|
||||
|
||||
{ ngx_string("server_addr"), NULL, ngx_http_variable_server_addr, 0, 0, 0 },
|
||||
|
||||
@@ -1293,11 +1303,22 @@ static ngx_int_t
|
||||
ngx_http_variable_proxy_protocol_addr(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data)
|
||||
{
|
||||
v->len = r->connection->proxy_protocol_addr.len;
|
||||
ngx_str_t *addr;
|
||||
ngx_proxy_protocol_t *pp;
|
||||
|
||||
pp = r->connection->proxy_protocol;
|
||||
if (pp == NULL) {
|
||||
v->not_found = 1;
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
addr = (ngx_str_t *) ((char *) pp + data);
|
||||
|
||||
v->len = addr->len;
|
||||
v->valid = 1;
|
||||
v->no_cacheable = 0;
|
||||
v->not_found = 0;
|
||||
v->data = r->connection->proxy_protocol_addr.data;
|
||||
v->data = addr->data;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
@@ -1307,7 +1328,14 @@ static ngx_int_t
|
||||
ngx_http_variable_proxy_protocol_port(ngx_http_request_t *r,
|
||||
ngx_http_variable_value_t *v, uintptr_t data)
|
||||
{
|
||||
ngx_uint_t port;
|
||||
ngx_uint_t port;
|
||||
ngx_proxy_protocol_t *pp;
|
||||
|
||||
pp = r->connection->proxy_protocol;
|
||||
if (pp == NULL) {
|
||||
v->not_found = 1;
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
v->len = 0;
|
||||
v->valid = 1;
|
||||
@@ -1319,7 +1347,7 @@ ngx_http_variable_proxy_protocol_port(ngx_http_request_t *r,
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
port = r->connection->proxy_protocol_port;
|
||||
port = *(in_port_t *) ((char *) pp + data);
|
||||
|
||||
if (port > 0 && port < 65536) {
|
||||
v->len = ngx_sprintf(v->data, "%ui", port) - v->data;
|
||||
|
||||
Reference in New Issue
Block a user