Compare commits
4
Commits
50320dd197
...
d12bc8b656
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d12bc8b656
|
||
|
|
7451bdd624
|
||
|
|
38c401869f
|
||
|
|
8be97f4f6c
|
@@ -443,3 +443,4 @@ d2fd76709909767fc727a5b4affcf1dc9ca488a7 release-1.15.9
|
|||||||
2fc9f853a6b7cd29dc84e0af2ed3cf78e0da6ca8 release-1.17.2
|
2fc9f853a6b7cd29dc84e0af2ed3cf78e0da6ca8 release-1.17.2
|
||||||
ed4303aa1b31a9aad5440640c0840d9d0af45fed release-1.17.3
|
ed4303aa1b31a9aad5440640c0840d9d0af45fed release-1.17.3
|
||||||
ce2ced3856909f36f8130c99eaa4dbdbae636ddc release-1.17.4
|
ce2ced3856909f36f8130c99eaa4dbdbae636ddc release-1.17.4
|
||||||
|
9af0dddbddb2c368bfedd2801bc100ffad01e19b release-1.17.5
|
||||||
@@ -5,6 +5,69 @@
|
|||||||
<change_log title="nginx">
|
<change_log title="nginx">
|
||||||
|
|
||||||
|
|
||||||
|
<changes ver="1.17.5" date="2019-10-22">
|
||||||
|
|
||||||
|
<change type="feature">
|
||||||
|
<para lang="ru">
|
||||||
|
теперь nginx использует вызов ioctl(FIONREAD), если он доступен,
|
||||||
|
чтобы избежать чтения из быстрого соединения в течение долгого времени.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
now nginx uses ioctl(FIONREAD), if available,
|
||||||
|
to avoid reading from a fast connection for a long time.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
неполные закодированные символы в конце URI запроса игнорировались.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
incomplete escaped characters at the end of the request URI were ignored.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
"/." и "/.." в конце URI запроса не нормализовывались.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
"/." and "/.." at the end of the request URI were not normalized.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
в директиве merge_slashes.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
in the "merge_slashes" directive.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
в директиве ignore_invalid_headers.<br/>
|
||||||
|
Спасибо Alan Kemp.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
in the "ignore_invalid_headers" directive.<br/>
|
||||||
|
Thanks to Alan Kemp.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
<change type="bugfix">
|
||||||
|
<para lang="ru">
|
||||||
|
nginx не собирался с MinGW-w64 gcc 8.1 и новее.
|
||||||
|
</para>
|
||||||
|
<para lang="en">
|
||||||
|
nginx could not be built with MinGW-w64 gcc 8.1 or newer.
|
||||||
|
</para>
|
||||||
|
</change>
|
||||||
|
|
||||||
|
</changes>
|
||||||
|
|
||||||
|
|
||||||
<changes ver="1.17.4" date="2019-09-24">
|
<changes ver="1.17.4" date="2019-09-24">
|
||||||
|
|
||||||
<change type="change">
|
<change type="change">
|
||||||
|
|||||||
+2
-2
@@ -9,8 +9,8 @@
|
|||||||
#define _NGINX_H_INCLUDED_
|
#define _NGINX_H_INCLUDED_
|
||||||
|
|
||||||
|
|
||||||
#define nginx_version 1017005
|
#define nginx_version 1017006
|
||||||
#define NGINX_VERSION "1.17.5"
|
#define NGINX_VERSION "1.17.6"
|
||||||
#define NGINX_VER "nginx/" NGINX_VERSION " by Hakase"
|
#define NGINX_VER "nginx/" NGINX_VERSION " by Hakase"
|
||||||
|
|
||||||
#ifndef NGINX_SERVER
|
#ifndef NGINX_SERVER
|
||||||
|
|||||||
@@ -147,8 +147,7 @@ struct ngx_connection_s {
|
|||||||
socklen_t socklen;
|
socklen_t socklen;
|
||||||
ngx_str_t addr_text;
|
ngx_str_t addr_text;
|
||||||
|
|
||||||
ngx_str_t proxy_protocol_addr;
|
ngx_proxy_protocol_t *proxy_protocol;
|
||||||
in_port_t proxy_protocol_port;
|
|
||||||
|
|
||||||
#if (NGX_SSL || NGX_COMPAT)
|
#if (NGX_SSL || NGX_COMPAT)
|
||||||
ngx_ssl_connection_t *ssl;
|
ngx_ssl_connection_t *ssl;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ typedef struct ngx_event_aio_s ngx_event_aio_t;
|
|||||||
typedef struct ngx_connection_s ngx_connection_t;
|
typedef struct ngx_connection_s ngx_connection_t;
|
||||||
typedef struct ngx_thread_task_s ngx_thread_task_t;
|
typedef struct ngx_thread_task_s ngx_thread_task_t;
|
||||||
typedef struct ngx_ssl_s ngx_ssl_t;
|
typedef struct ngx_ssl_s ngx_ssl_t;
|
||||||
|
typedef struct ngx_proxy_protocol_s ngx_proxy_protocol_t;
|
||||||
typedef struct ngx_ssl_connection_s ngx_ssl_connection_t;
|
typedef struct ngx_ssl_connection_s ngx_ssl_connection_t;
|
||||||
typedef struct ngx_udp_connection_s ngx_udp_connection_t;
|
typedef struct ngx_udp_connection_s ngx_udp_connection_t;
|
||||||
|
|
||||||
|
|||||||
+158
-79
@@ -40,6 +40,10 @@ typedef struct {
|
|||||||
} ngx_proxy_protocol_inet6_addrs_t;
|
} ngx_proxy_protocol_inet6_addrs_t;
|
||||||
|
|
||||||
|
|
||||||
|
static u_char *ngx_proxy_protocol_read_addr(ngx_connection_t *c, u_char *p,
|
||||||
|
u_char *last, ngx_str_t *addr);
|
||||||
|
static u_char *ngx_proxy_protocol_read_port(u_char *p, u_char *last,
|
||||||
|
in_port_t *port, u_char sep);
|
||||||
static u_char *ngx_proxy_protocol_v2_read(ngx_connection_t *c, u_char *buf,
|
static u_char *ngx_proxy_protocol_v2_read(ngx_connection_t *c, u_char *buf,
|
||||||
u_char *last);
|
u_char *last);
|
||||||
|
|
||||||
@@ -47,9 +51,9 @@ static u_char *ngx_proxy_protocol_v2_read(ngx_connection_t *c, u_char *buf,
|
|||||||
u_char *
|
u_char *
|
||||||
ngx_proxy_protocol_read(ngx_connection_t *c, u_char *buf, u_char *last)
|
ngx_proxy_protocol_read(ngx_connection_t *c, u_char *buf, u_char *last)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
u_char ch, *p, *addr, *port;
|
u_char *p;
|
||||||
ngx_int_t n;
|
ngx_proxy_protocol_t *pp;
|
||||||
|
|
||||||
static const u_char signature[] = "\r\n\r\n\0\r\nQUIT\n";
|
static const u_char signature[] = "\r\n\r\n\0\r\nQUIT\n";
|
||||||
|
|
||||||
@@ -83,73 +87,47 @@ ngx_proxy_protocol_read(ngx_connection_t *c, u_char *buf, u_char *last)
|
|||||||
}
|
}
|
||||||
|
|
||||||
p += 5;
|
p += 5;
|
||||||
addr = p;
|
|
||||||
|
|
||||||
for ( ;; ) {
|
pp = ngx_pcalloc(c->pool, sizeof(ngx_proxy_protocol_t));
|
||||||
if (p == last) {
|
if (pp == NULL) {
|
||||||
goto invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
ch = *p++;
|
|
||||||
|
|
||||||
if (ch == ' ') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ch != ':' && ch != '.'
|
|
||||||
&& (ch < 'a' || ch > 'f')
|
|
||||||
&& (ch < 'A' || ch > 'F')
|
|
||||||
&& (ch < '0' || ch > '9'))
|
|
||||||
{
|
|
||||||
goto invalid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
len = p - addr - 1;
|
|
||||||
c->proxy_protocol_addr.data = ngx_pnalloc(c->pool, len);
|
|
||||||
|
|
||||||
if (c->proxy_protocol_addr.data == NULL) {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_memcpy(c->proxy_protocol_addr.data, addr, len);
|
p = ngx_proxy_protocol_read_addr(c, p, last, &pp->src_addr);
|
||||||
c->proxy_protocol_addr.len = len;
|
if (p == NULL) {
|
||||||
|
|
||||||
for ( ;; ) {
|
|
||||||
if (p == last) {
|
|
||||||
goto invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*p++ == ' ') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
port = p;
|
|
||||||
|
|
||||||
for ( ;; ) {
|
|
||||||
if (p == last) {
|
|
||||||
goto invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*p++ == ' ') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
len = p - port - 1;
|
|
||||||
|
|
||||||
n = ngx_atoi(port, len);
|
|
||||||
|
|
||||||
if (n < 0 || n > 65535) {
|
|
||||||
goto invalid;
|
goto invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->proxy_protocol_port = (in_port_t) n;
|
p = ngx_proxy_protocol_read_addr(c, p, last, &pp->dst_addr);
|
||||||
|
if (p == NULL) {
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
|
||||||
ngx_log_debug2(NGX_LOG_DEBUG_CORE, c->log, 0,
|
p = ngx_proxy_protocol_read_port(p, last, &pp->src_port, ' ');
|
||||||
"PROXY protocol address: %V %d", &c->proxy_protocol_addr,
|
if (p == NULL) {
|
||||||
c->proxy_protocol_port);
|
goto invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = ngx_proxy_protocol_read_port(p, last, &pp->dst_port, CR);
|
||||||
|
if (p == NULL) {
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p == last) {
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*p++ != LF) {
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_log_debug4(NGX_LOG_DEBUG_CORE, c->log, 0,
|
||||||
|
"PROXY protocol src: %V %d, dst: %V %d",
|
||||||
|
&pp->src_addr, pp->src_port, &pp->dst_addr, pp->dst_port);
|
||||||
|
|
||||||
|
c->proxy_protocol = pp;
|
||||||
|
|
||||||
|
return p;
|
||||||
|
|
||||||
skip:
|
skip:
|
||||||
|
|
||||||
@@ -168,6 +146,82 @@ invalid:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static u_char *
|
||||||
|
ngx_proxy_protocol_read_addr(ngx_connection_t *c, u_char *p, u_char *last,
|
||||||
|
ngx_str_t *addr)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
u_char ch, *pos;
|
||||||
|
|
||||||
|
pos = p;
|
||||||
|
|
||||||
|
for ( ;; ) {
|
||||||
|
if (p == last) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ch = *p++;
|
||||||
|
|
||||||
|
if (ch == ' ') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ch != ':' && ch != '.'
|
||||||
|
&& (ch < 'a' || ch > 'f')
|
||||||
|
&& (ch < 'A' || ch > 'F')
|
||||||
|
&& (ch < '0' || ch > '9'))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
len = p - pos - 1;
|
||||||
|
|
||||||
|
addr->data = ngx_pnalloc(c->pool, len);
|
||||||
|
if (addr->data == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngx_memcpy(addr->data, pos, len);
|
||||||
|
addr->len = len;
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static u_char *
|
||||||
|
ngx_proxy_protocol_read_port(u_char *p, u_char *last, in_port_t *port,
|
||||||
|
u_char sep)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
u_char *pos;
|
||||||
|
ngx_int_t n;
|
||||||
|
|
||||||
|
pos = p;
|
||||||
|
|
||||||
|
for ( ;; ) {
|
||||||
|
if (p == last) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*p++ == sep) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
len = p - pos - 1;
|
||||||
|
|
||||||
|
n = ngx_atoi(pos, len);
|
||||||
|
if (n < 0 || n > 65535) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
*port = (in_port_t) n;
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
u_char *
|
u_char *
|
||||||
ngx_proxy_protocol_write(ngx_connection_t *c, u_char *buf, u_char *last)
|
ngx_proxy_protocol_write(ngx_connection_t *c, u_char *buf, u_char *last)
|
||||||
{
|
{
|
||||||
@@ -219,7 +273,8 @@ ngx_proxy_protocol_v2_read(ngx_connection_t *c, u_char *buf, u_char *last)
|
|||||||
size_t len;
|
size_t len;
|
||||||
socklen_t socklen;
|
socklen_t socklen;
|
||||||
ngx_uint_t version, command, family, transport;
|
ngx_uint_t version, command, family, transport;
|
||||||
ngx_sockaddr_t sockaddr;
|
ngx_sockaddr_t src_sockaddr, dst_sockaddr;
|
||||||
|
ngx_proxy_protocol_t *pp;
|
||||||
ngx_proxy_protocol_header_t *header;
|
ngx_proxy_protocol_header_t *header;
|
||||||
ngx_proxy_protocol_inet_addrs_t *in;
|
ngx_proxy_protocol_inet_addrs_t *in;
|
||||||
#if (NGX_HAVE_INET6)
|
#if (NGX_HAVE_INET6)
|
||||||
@@ -266,6 +321,11 @@ ngx_proxy_protocol_v2_read(ngx_connection_t *c, u_char *buf, u_char *last)
|
|||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pp = ngx_pcalloc(c->pool, sizeof(ngx_proxy_protocol_t));
|
||||||
|
if (pp == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
family = header->family_transport >> 4;
|
family = header->family_transport >> 4;
|
||||||
|
|
||||||
switch (family) {
|
switch (family) {
|
||||||
@@ -278,11 +338,16 @@ ngx_proxy_protocol_v2_read(ngx_connection_t *c, u_char *buf, u_char *last)
|
|||||||
|
|
||||||
in = (ngx_proxy_protocol_inet_addrs_t *) buf;
|
in = (ngx_proxy_protocol_inet_addrs_t *) buf;
|
||||||
|
|
||||||
sockaddr.sockaddr_in.sin_family = AF_INET;
|
src_sockaddr.sockaddr_in.sin_family = AF_INET;
|
||||||
sockaddr.sockaddr_in.sin_port = 0;
|
src_sockaddr.sockaddr_in.sin_port = 0;
|
||||||
memcpy(&sockaddr.sockaddr_in.sin_addr, in->src_addr, 4);
|
memcpy(&src_sockaddr.sockaddr_in.sin_addr, in->src_addr, 4);
|
||||||
|
|
||||||
c->proxy_protocol_port = ngx_proxy_protocol_parse_uint16(in->src_port);
|
dst_sockaddr.sockaddr_in.sin_family = AF_INET;
|
||||||
|
dst_sockaddr.sockaddr_in.sin_port = 0;
|
||||||
|
memcpy(&dst_sockaddr.sockaddr_in.sin_addr, in->dst_addr, 4);
|
||||||
|
|
||||||
|
pp->src_port = ngx_proxy_protocol_parse_uint16(in->src_port);
|
||||||
|
pp->dst_port = ngx_proxy_protocol_parse_uint16(in->dst_port);
|
||||||
|
|
||||||
socklen = sizeof(struct sockaddr_in);
|
socklen = sizeof(struct sockaddr_in);
|
||||||
|
|
||||||
@@ -300,11 +365,16 @@ ngx_proxy_protocol_v2_read(ngx_connection_t *c, u_char *buf, u_char *last)
|
|||||||
|
|
||||||
in6 = (ngx_proxy_protocol_inet6_addrs_t *) buf;
|
in6 = (ngx_proxy_protocol_inet6_addrs_t *) buf;
|
||||||
|
|
||||||
sockaddr.sockaddr_in6.sin6_family = AF_INET6;
|
src_sockaddr.sockaddr_in6.sin6_family = AF_INET6;
|
||||||
sockaddr.sockaddr_in6.sin6_port = 0;
|
src_sockaddr.sockaddr_in6.sin6_port = 0;
|
||||||
memcpy(&sockaddr.sockaddr_in6.sin6_addr, in6->src_addr, 16);
|
memcpy(&src_sockaddr.sockaddr_in6.sin6_addr, in6->src_addr, 16);
|
||||||
|
|
||||||
c->proxy_protocol_port = ngx_proxy_protocol_parse_uint16(in6->src_port);
|
dst_sockaddr.sockaddr_in6.sin6_family = AF_INET6;
|
||||||
|
dst_sockaddr.sockaddr_in6.sin6_port = 0;
|
||||||
|
memcpy(&dst_sockaddr.sockaddr_in6.sin6_addr, in6->dst_addr, 16);
|
||||||
|
|
||||||
|
pp->src_port = ngx_proxy_protocol_parse_uint16(in6->src_port);
|
||||||
|
pp->dst_port = ngx_proxy_protocol_parse_uint16(in6->dst_port);
|
||||||
|
|
||||||
socklen = sizeof(struct sockaddr_in6);
|
socklen = sizeof(struct sockaddr_in6);
|
||||||
|
|
||||||
@@ -321,23 +391,32 @@ ngx_proxy_protocol_v2_read(ngx_connection_t *c, u_char *buf, u_char *last)
|
|||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->proxy_protocol_addr.data = ngx_pnalloc(c->pool, NGX_SOCKADDR_STRLEN);
|
pp->src_addr.data = ngx_pnalloc(c->pool, NGX_SOCKADDR_STRLEN);
|
||||||
if (c->proxy_protocol_addr.data == NULL) {
|
if (pp->src_addr.data == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->proxy_protocol_addr.len = ngx_sock_ntop(&sockaddr.sockaddr, socklen,
|
pp->src_addr.len = ngx_sock_ntop(&src_sockaddr.sockaddr, socklen,
|
||||||
c->proxy_protocol_addr.data,
|
pp->src_addr.data, NGX_SOCKADDR_STRLEN, 0);
|
||||||
NGX_SOCKADDR_STRLEN, 0);
|
|
||||||
|
|
||||||
ngx_log_debug2(NGX_LOG_DEBUG_CORE, c->log, 0,
|
pp->dst_addr.data = ngx_pnalloc(c->pool, NGX_SOCKADDR_STRLEN);
|
||||||
"PROXY protocol v2 address: %V %d", &c->proxy_protocol_addr,
|
if (pp->dst_addr.data == NULL) {
|
||||||
c->proxy_protocol_port);
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
pp->dst_addr.len = ngx_sock_ntop(&dst_sockaddr.sockaddr, socklen,
|
||||||
|
pp->dst_addr.data, NGX_SOCKADDR_STRLEN, 0);
|
||||||
|
|
||||||
|
ngx_log_debug4(NGX_LOG_DEBUG_CORE, c->log, 0,
|
||||||
|
"PROXY protocol v2 src: %V %d, dst: %V %d",
|
||||||
|
&pp->src_addr, pp->src_port, &pp->dst_addr, pp->dst_port);
|
||||||
|
|
||||||
if (buf < end) {
|
if (buf < end) {
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, c->log, 0,
|
||||||
"PROXY protocol v2 %z bytes of tlv ignored", end - buf);
|
"PROXY protocol v2 %z bytes of tlv ignored", end - buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c->proxy_protocol = pp;
|
||||||
|
|
||||||
return end;
|
return end;
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,14 @@
|
|||||||
#define NGX_PROXY_PROTOCOL_MAX_HEADER 107
|
#define NGX_PROXY_PROTOCOL_MAX_HEADER 107
|
||||||
|
|
||||||
|
|
||||||
|
struct ngx_proxy_protocol_s {
|
||||||
|
ngx_str_t src_addr;
|
||||||
|
ngx_str_t dst_addr;
|
||||||
|
in_port_t src_port;
|
||||||
|
in_port_t dst_port;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
u_char *ngx_proxy_protocol_read(ngx_connection_t *c, u_char *buf,
|
u_char *ngx_proxy_protocol_read(ngx_connection_t *c, u_char *buf,
|
||||||
u_char *last);
|
u_char *last);
|
||||||
u_char *ngx_proxy_protocol_write(ngx_connection_t *c, u_char *buf,
|
u_char *ngx_proxy_protocol_write(ngx_connection_t *c, u_char *buf,
|
||||||
|
|||||||
@@ -180,12 +180,11 @@ ngx_http_realip_handler(ngx_http_request_t *r)
|
|||||||
|
|
||||||
case NGX_HTTP_REALIP_PROXY:
|
case NGX_HTTP_REALIP_PROXY:
|
||||||
|
|
||||||
value = &r->connection->proxy_protocol_addr;
|
if (r->connection->proxy_protocol == NULL) {
|
||||||
|
|
||||||
if (value->len == 0) {
|
|
||||||
return NGX_DECLINED;
|
return NGX_DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
value = &r->connection->proxy_protocol->src_addr;
|
||||||
xfwd = NULL;
|
xfwd = NULL;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -238,7 +237,7 @@ found:
|
|||||||
!= NGX_DECLINED)
|
!= NGX_DECLINED)
|
||||||
{
|
{
|
||||||
if (rlcf->type == NGX_HTTP_REALIP_PROXY) {
|
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);
|
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("remote_port"), NULL, ngx_http_variable_remote_port, 0, 0, 0 },
|
||||||
|
|
||||||
{ ngx_string("proxy_protocol_addr"), NULL,
|
{ 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_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 },
|
{ 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_proxy_protocol_addr(ngx_http_request_t *r,
|
||||||
ngx_http_variable_value_t *v, uintptr_t data)
|
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->valid = 1;
|
||||||
v->no_cacheable = 0;
|
v->no_cacheable = 0;
|
||||||
v->not_found = 0;
|
v->not_found = 0;
|
||||||
v->data = r->connection->proxy_protocol_addr.data;
|
v->data = addr->data;
|
||||||
|
|
||||||
return NGX_OK;
|
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_proxy_protocol_port(ngx_http_request_t *r,
|
||||||
ngx_http_variable_value_t *v, uintptr_t data)
|
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->len = 0;
|
||||||
v->valid = 1;
|
v->valid = 1;
|
||||||
@@ -1319,7 +1347,7 @@ ngx_http_variable_proxy_protocol_port(ngx_http_request_t *r,
|
|||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
port = r->connection->proxy_protocol_port;
|
port = *(in_port_t *) ((char *) pp + data);
|
||||||
|
|
||||||
if (port > 0 && port < 65536) {
|
if (port > 0 && port < 65536) {
|
||||||
v->len = ngx_sprintf(v->data, "%ui", port) - v->data;
|
v->len = ngx_sprintf(v->data, "%ui", port) - v->data;
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ ngx_strerror(ngx_err_t err, u_char *errstr, size_t size)
|
|||||||
len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
len = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
|
||||||
NULL, err, lang, (char *) errstr, size, NULL);
|
NULL, err, lang, (char *) errstr, size, NULL);
|
||||||
|
|
||||||
if (len == 0 && lang && GetLastError() == ERROR_RESOURCE_LANG_NOT_FOUND) {
|
if (len == 0 && lang) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Try to use English messages first and fallback to a language,
|
* Try to use English messages first and fallback to a language,
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ ngx_os_init(ngx_log_t *log)
|
|||||||
goto nopoll;
|
goto nopoll;
|
||||||
}
|
}
|
||||||
|
|
||||||
WSAPoll = (ngx_wsapoll_pt) GetProcAddress(hmod, "WSAPoll");
|
WSAPoll = (ngx_wsapoll_pt) (void *) GetProcAddress(hmod, "WSAPoll");
|
||||||
if (WSAPoll == NULL) {
|
if (WSAPoll == NULL) {
|
||||||
ngx_log_error(NGX_LOG_NOTICE, log, ngx_errno,
|
ngx_log_error(NGX_LOG_NOTICE, log, ngx_errno,
|
||||||
"GetProcAddress(\"WSAPoll\") failed");
|
"GetProcAddress(\"WSAPoll\") failed");
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ ngx_stream_realip_handler(ngx_stream_session_t *s)
|
|||||||
|
|
||||||
c = s->connection;
|
c = s->connection;
|
||||||
|
|
||||||
if (c->proxy_protocol_addr.len == 0) {
|
if (c->proxy_protocol == NULL) {
|
||||||
return NGX_DECLINED;
|
return NGX_DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,14 +116,14 @@ ngx_stream_realip_handler(ngx_stream_session_t *s)
|
|||||||
return NGX_DECLINED;
|
return NGX_DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ngx_parse_addr(c->pool, &addr, c->proxy_protocol_addr.data,
|
if (ngx_parse_addr(c->pool, &addr, c->proxy_protocol->src_addr.data,
|
||||||
c->proxy_protocol_addr.len)
|
c->proxy_protocol->src_addr.len)
|
||||||
!= NGX_OK)
|
!= NGX_OK)
|
||||||
{
|
{
|
||||||
return NGX_DECLINED;
|
return NGX_DECLINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ngx_inet_set_port(addr.sockaddr, c->proxy_protocol_port);
|
ngx_inet_set_port(addr.sockaddr, c->proxy_protocol->src_port);
|
||||||
|
|
||||||
return ngx_stream_realip_set_addr(s, &addr);
|
return ngx_stream_realip_set_addr(s, &addr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,10 +64,20 @@ static ngx_stream_variable_t ngx_stream_core_variables[] = {
|
|||||||
ngx_stream_variable_remote_port, 0, 0, 0 },
|
ngx_stream_variable_remote_port, 0, 0, 0 },
|
||||||
|
|
||||||
{ ngx_string("proxy_protocol_addr"), NULL,
|
{ ngx_string("proxy_protocol_addr"), NULL,
|
||||||
ngx_stream_variable_proxy_protocol_addr, 0, 0, 0 },
|
ngx_stream_variable_proxy_protocol_addr,
|
||||||
|
offsetof(ngx_proxy_protocol_t, src_addr), 0, 0 },
|
||||||
|
|
||||||
{ ngx_string("proxy_protocol_port"), NULL,
|
{ ngx_string("proxy_protocol_port"), NULL,
|
||||||
ngx_stream_variable_proxy_protocol_port, 0, 0, 0 },
|
ngx_stream_variable_proxy_protocol_port,
|
||||||
|
offsetof(ngx_proxy_protocol_t, src_port), 0, 0 },
|
||||||
|
|
||||||
|
{ ngx_string("proxy_protocol_server_addr"), NULL,
|
||||||
|
ngx_stream_variable_proxy_protocol_addr,
|
||||||
|
offsetof(ngx_proxy_protocol_t, dst_addr), 0, 0 },
|
||||||
|
|
||||||
|
{ ngx_string("proxy_protocol_server_port"), NULL,
|
||||||
|
ngx_stream_variable_proxy_protocol_port,
|
||||||
|
offsetof(ngx_proxy_protocol_t, dst_port), 0, 0 },
|
||||||
|
|
||||||
{ ngx_string("server_addr"), NULL,
|
{ ngx_string("server_addr"), NULL,
|
||||||
ngx_stream_variable_server_addr, 0, 0, 0 },
|
ngx_stream_variable_server_addr, 0, 0, 0 },
|
||||||
@@ -557,11 +567,22 @@ static ngx_int_t
|
|||||||
ngx_stream_variable_proxy_protocol_addr(ngx_stream_session_t *s,
|
ngx_stream_variable_proxy_protocol_addr(ngx_stream_session_t *s,
|
||||||
ngx_stream_variable_value_t *v, uintptr_t data)
|
ngx_stream_variable_value_t *v, uintptr_t data)
|
||||||
{
|
{
|
||||||
v->len = s->connection->proxy_protocol_addr.len;
|
ngx_str_t *addr;
|
||||||
|
ngx_proxy_protocol_t *pp;
|
||||||
|
|
||||||
|
pp = s->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->valid = 1;
|
||||||
v->no_cacheable = 0;
|
v->no_cacheable = 0;
|
||||||
v->not_found = 0;
|
v->not_found = 0;
|
||||||
v->data = s->connection->proxy_protocol_addr.data;
|
v->data = addr->data;
|
||||||
|
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
@@ -571,7 +592,14 @@ static ngx_int_t
|
|||||||
ngx_stream_variable_proxy_protocol_port(ngx_stream_session_t *s,
|
ngx_stream_variable_proxy_protocol_port(ngx_stream_session_t *s,
|
||||||
ngx_stream_variable_value_t *v, uintptr_t data)
|
ngx_stream_variable_value_t *v, uintptr_t data)
|
||||||
{
|
{
|
||||||
ngx_uint_t port;
|
ngx_uint_t port;
|
||||||
|
ngx_proxy_protocol_t *pp;
|
||||||
|
|
||||||
|
pp = s->connection->proxy_protocol;
|
||||||
|
if (pp == NULL) {
|
||||||
|
v->not_found = 1;
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
|
||||||
v->len = 0;
|
v->len = 0;
|
||||||
v->valid = 1;
|
v->valid = 1;
|
||||||
@@ -583,7 +611,7 @@ ngx_stream_variable_proxy_protocol_port(ngx_stream_session_t *s,
|
|||||||
return NGX_ERROR;
|
return NGX_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
port = s->connection->proxy_protocol_port;
|
port = *(in_port_t *) ((char *) pp + data);
|
||||||
|
|
||||||
if (port > 0 && port < 65536) {
|
if (port > 0 && port < 65536) {
|
||||||
v->len = ngx_sprintf(v->data, "%ui", port) - v->data;
|
v->len = ngx_sprintf(v->data, "%ui", port) - v->data;
|
||||||
|
|||||||
Reference in New Issue
Block a user