Skip to content

Commit 18c8707

Browse files
committed
nginx 1.23.1
1 parent c2c8095 commit 18c8707

File tree

12 files changed

+354
-43
lines changed

12 files changed

+354
-43
lines changed

nginx/CHANGES

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11

2+
Changes with nginx 1.23.1 19 Jul 2022
3+
4+
*) Feature: memory usage optimization in configurations with SSL
5+
proxying.
6+
7+
*) Feature: looking up of IPv4 addresses while resolving now can be
8+
disabled with the "ipv4=off" parameter of the "resolver" directive.
9+
10+
*) Change: the logging level of the "bad key share", "bad extension",
11+
"bad cipher", and "bad ecpoint" SSL errors has been lowered from
12+
"crit" to "info".
13+
14+
*) Bugfix: while returning byte ranges nginx did not remove the
15+
"Content-Range" header line if it was present in the original backend
16+
response.
17+
18+
*) Bugfix: a proxied response might be truncated during reconfiguration
19+
on Linux; the bug had appeared in 1.17.5.
20+
21+
222
Changes with nginx 1.23.0 21 Jun 2022
323

424
*) Change in internal API: now header lines are represented as linked

nginx/CHANGES.ru

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11

2+
Изменения в nginx 1.23.1 19.07.2022
3+
4+
*) Добавление: оптимизация использования памяти в конфигурациях с
5+
SSL-проксированием.
6+
7+
*) Добавление: теперь с помощью параметра "ipv4=off" директивы
8+
"resolver" можно запретить поиск IPv4-адресов при преобразовании имён
9+
в адреса.
10+
11+
*) Изменение: уровень логгирования ошибок SSL "bad key share", "bad
12+
extension", "bad cipher" и "bad ecpoint" понижен с уровня crit до
13+
info.
14+
15+
*) Исправление: при возврате диапазонов nginx не удалял строку заголовка
16+
"Content-Range", если она присутствовала в исходном ответе бэкенда.
17+
18+
*) Исправление: проксированный ответ мог быть отправлен не полностью при
19+
переконфигурации на Linux; ошибка появилась в 1.17.5.
20+
21+
222
Изменения в nginx 1.23.0 21.06.2022
323

424
*) Изменение во внутреннем API: теперь строки заголовков представлены

nginx/src/core/nginx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#define _NGINX_H_INCLUDED_
1010

1111

12-
#define nginx_version 1023000
13-
#define NGINX_VERSION "1.23.0"
12+
#define nginx_version 1023001
13+
#define NGINX_VERSION "1.23.1"
1414
#define NGINX_VER "nginx/" NGINX_VERSION
1515

1616
#ifdef NGX_BUILD

nginx/src/core/ngx_resolver.c

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n)
157157
cln->handler = ngx_resolver_cleanup;
158158
cln->data = r;
159159

160+
r->ipv4 = 1;
161+
160162
ngx_rbtree_init(&r->name_rbtree, &r->name_sentinel,
161163
ngx_resolver_rbtree_insert_value);
162164

@@ -225,6 +227,23 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n)
225227
}
226228

227229
#if (NGX_HAVE_INET6)
230+
if (ngx_strncmp(names[i].data, "ipv4=", 5) == 0) {
231+
232+
if (ngx_strcmp(&names[i].data[5], "on") == 0) {
233+
r->ipv4 = 1;
234+
235+
} else if (ngx_strcmp(&names[i].data[5], "off") == 0) {
236+
r->ipv4 = 0;
237+
238+
} else {
239+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
240+
"invalid parameter: %V", &names[i]);
241+
return NULL;
242+
}
243+
244+
continue;
245+
}
246+
228247
if (ngx_strncmp(names[i].data, "ipv6=", 5) == 0) {
229248

230249
if (ngx_strcmp(&names[i].data[5], "on") == 0) {
@@ -273,6 +292,14 @@ ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n)
273292
}
274293
}
275294

295+
#if (NGX_HAVE_INET6)
296+
if (r->ipv4 + r->ipv6 == 0) {
297+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
298+
"\"ipv4\" and \"ipv6\" cannot both be \"off\"");
299+
return NULL;
300+
}
301+
#endif
302+
276303
if (n && r->connections.nelts == 0) {
277304
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "no name servers defined");
278305
return NULL;
@@ -836,7 +863,7 @@ ngx_resolve_name_locked(ngx_resolver_t *r, ngx_resolver_ctx_t *ctx,
836863
r->last_connection = 0;
837864
}
838865

839-
rn->naddrs = (u_short) -1;
866+
rn->naddrs = r->ipv4 ? (u_short) -1 : 0;
840867
rn->tcp = 0;
841868
#if (NGX_HAVE_INET6)
842869
rn->naddrs6 = r->ipv6 ? (u_short) -1 : 0;
@@ -1263,7 +1290,7 @@ ngx_resolver_send_query(ngx_resolver_t *r, ngx_resolver_node_t *rn)
12631290
rec->log.action = "resolving";
12641291
}
12651292

1266-
if (rn->naddrs == (u_short) -1) {
1293+
if (rn->query && rn->naddrs == (u_short) -1) {
12671294
rc = rn->tcp ? ngx_resolver_send_tcp_query(r, rec, rn->query, rn->qlen)
12681295
: ngx_resolver_send_udp_query(r, rec, rn->query, rn->qlen);
12691296

@@ -1765,10 +1792,13 @@ ngx_resolver_process_response(ngx_resolver_t *r, u_char *buf, size_t n,
17651792
q = ngx_queue_next(q))
17661793
{
17671794
rn = ngx_queue_data(q, ngx_resolver_node_t, queue);
1768-
qident = (rn->query[0] << 8) + rn->query[1];
17691795

1770-
if (qident == ident) {
1771-
goto dns_error_name;
1796+
if (rn->query) {
1797+
qident = (rn->query[0] << 8) + rn->query[1];
1798+
1799+
if (qident == ident) {
1800+
goto dns_error_name;
1801+
}
17721802
}
17731803

17741804
#if (NGX_HAVE_INET6)
@@ -3645,7 +3675,7 @@ ngx_resolver_create_name_query(ngx_resolver_t *r, ngx_resolver_node_t *rn,
36453675
len = sizeof(ngx_resolver_hdr_t) + nlen + sizeof(ngx_resolver_qs_t);
36463676

36473677
#if (NGX_HAVE_INET6)
3648-
p = ngx_resolver_alloc(r, r->ipv6 ? len * 2 : len);
3678+
p = ngx_resolver_alloc(r, len * (r->ipv4 + r->ipv6));
36493679
#else
36503680
p = ngx_resolver_alloc(r, len);
36513681
#endif
@@ -3658,19 +3688,21 @@ ngx_resolver_create_name_query(ngx_resolver_t *r, ngx_resolver_node_t *rn,
36583688

36593689
#if (NGX_HAVE_INET6)
36603690
if (r->ipv6) {
3661-
rn->query6 = p + len;
3691+
rn->query6 = r->ipv4 ? (p + len) : p;
36623692
}
36633693
#endif
36643694

36653695
query = (ngx_resolver_hdr_t *) p;
36663696

3667-
ident = ngx_random();
3697+
if (r->ipv4) {
3698+
ident = ngx_random();
36683699

3669-
ngx_log_debug2(NGX_LOG_DEBUG_CORE, r->log, 0,
3670-
"resolve: \"%V\" A %i", name, ident & 0xffff);
3700+
ngx_log_debug2(NGX_LOG_DEBUG_CORE, r->log, 0,
3701+
"resolve: \"%V\" A %i", name, ident & 0xffff);
36713702

3672-
query->ident_hi = (u_char) ((ident >> 8) & 0xff);
3673-
query->ident_lo = (u_char) (ident & 0xff);
3703+
query->ident_hi = (u_char) ((ident >> 8) & 0xff);
3704+
query->ident_lo = (u_char) (ident & 0xff);
3705+
}
36743706

36753707
/* recursion query */
36763708
query->flags_hi = 1; query->flags_lo = 0;
@@ -3731,7 +3763,9 @@ ngx_resolver_create_name_query(ngx_resolver_t *r, ngx_resolver_node_t *rn,
37313763

37323764
p = rn->query6;
37333765

3734-
ngx_memcpy(p, rn->query, rn->qlen);
3766+
if (r->ipv4) {
3767+
ngx_memcpy(p, rn->query, rn->qlen);
3768+
}
37353769

37363770
query = (ngx_resolver_hdr_t *) p;
37373771

nginx/src/core/ngx_resolver.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,10 @@ struct ngx_resolver_s {
175175
ngx_queue_t srv_expire_queue;
176176
ngx_queue_t addr_expire_queue;
177177

178+
unsigned ipv4:1;
179+
178180
#if (NGX_HAVE_INET6)
179-
ngx_uint_t ipv6; /* unsigned ipv6:1; */
181+
unsigned ipv6:1;
180182
ngx_rbtree_t addr6_rbtree;
181183
ngx_rbtree_node_t addr6_sentinel;
182184
ngx_queue_t addr6_resend_queue;

nginx/src/event/ngx_event_openssl.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3343,6 +3343,12 @@ ngx_ssl_connection_error(ngx_connection_t *c, int sslerr, ngx_err_t err,
33433343
#ifdef SSL_R_NO_SUITABLE_KEY_SHARE
33443344
|| n == SSL_R_NO_SUITABLE_KEY_SHARE /* 101 */
33453345
#endif
3346+
#ifdef SSL_R_BAD_KEY_SHARE
3347+
|| n == SSL_R_BAD_KEY_SHARE /* 108 */
3348+
#endif
3349+
#ifdef SSL_R_BAD_EXTENSION
3350+
|| n == SSL_R_BAD_EXTENSION /* 110 */
3351+
#endif
33463352
#ifdef SSL_R_NO_SUITABLE_SIGNATURE_ALGORITHM
33473353
|| n == SSL_R_NO_SUITABLE_SIGNATURE_ALGORITHM /* 118 */
33483354
#endif
@@ -3357,6 +3363,9 @@ ngx_ssl_connection_error(ngx_connection_t *c, int sslerr, ngx_err_t err,
33573363
|| n == SSL_R_NO_CIPHERS_PASSED /* 182 */
33583364
#endif
33593365
|| n == SSL_R_NO_CIPHERS_SPECIFIED /* 183 */
3366+
#ifdef SSL_R_BAD_CIPHER
3367+
|| n == SSL_R_BAD_CIPHER /* 186 */
3368+
#endif
33603369
|| n == SSL_R_NO_COMPRESSION_SPECIFIED /* 187 */
33613370
|| n == SSL_R_NO_SHARED_CIPHER /* 193 */
33623371
|| n == SSL_R_RECORD_LENGTH_MISMATCH /* 213 */
@@ -3391,6 +3400,9 @@ ngx_ssl_connection_error(ngx_connection_t *c, int sslerr, ngx_err_t err,
33913400
#ifdef SSL_R_APPLICATION_DATA_ON_SHUTDOWN
33923401
|| n == SSL_R_APPLICATION_DATA_ON_SHUTDOWN /* 291 */
33933402
#endif
3403+
#ifdef SSL_R_BAD_ECPOINT
3404+
|| n == SSL_R_BAD_ECPOINT /* 306 */
3405+
#endif
33943406
#ifdef SSL_R_RENEGOTIATE_EXT_TOO_LONG
33953407
|| n == SSL_R_RENEGOTIATE_EXT_TOO_LONG /* 335 */
33963408
|| n == SSL_R_RENEGOTIATION_ENCODING_ERR /* 336 */

nginx/src/http/modules/ngx_http_grpc_module.c

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ static char *ngx_http_grpc_ssl_password_file(ngx_conf_t *cf,
209209
ngx_command_t *cmd, void *conf);
210210
static char *ngx_http_grpc_ssl_conf_command_check(ngx_conf_t *cf, void *post,
211211
void *data);
212+
static ngx_int_t ngx_http_grpc_merge_ssl(ngx_conf_t *cf,
213+
ngx_http_grpc_loc_conf_t *conf, ngx_http_grpc_loc_conf_t *prev);
212214
static ngx_int_t ngx_http_grpc_set_ssl(ngx_conf_t *cf,
213215
ngx_http_grpc_loc_conf_t *glcf);
214216
#endif
@@ -562,7 +564,7 @@ ngx_http_grpc_handler(ngx_http_request_t *r)
562564
ctx->host = glcf->host;
563565

564566
#if (NGX_HTTP_SSL)
565-
u->ssl = (glcf->upstream.ssl != NULL);
567+
u->ssl = glcf->ssl;
566568

567569
if (u->ssl) {
568570
ngx_str_set(&u->schema, "grpcs://");
@@ -4463,6 +4465,10 @@ ngx_http_grpc_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
44634465

44644466
#if (NGX_HTTP_SSL)
44654467

4468+
if (ngx_http_grpc_merge_ssl(cf, conf, prev) != NGX_OK) {
4469+
return NGX_CONF_ERROR;
4470+
}
4471+
44664472
ngx_conf_merge_value(conf->upstream.ssl_session_reuse,
44674473
prev->upstream.ssl_session_reuse, 1);
44684474

@@ -4524,7 +4530,7 @@ ngx_http_grpc_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
45244530
conf->grpc_values = prev->grpc_values;
45254531

45264532
#if (NGX_HTTP_SSL)
4527-
conf->upstream.ssl = prev->upstream.ssl;
4533+
conf->ssl = prev->ssl;
45284534
#endif
45294535
}
45304536

@@ -4874,16 +4880,62 @@ ngx_http_grpc_ssl_conf_command_check(ngx_conf_t *cf, void *post, void *data)
48744880

48754881

48764882
static ngx_int_t
4877-
ngx_http_grpc_set_ssl(ngx_conf_t *cf, ngx_http_grpc_loc_conf_t *glcf)
4883+
ngx_http_grpc_merge_ssl(ngx_conf_t *cf, ngx_http_grpc_loc_conf_t *conf,
4884+
ngx_http_grpc_loc_conf_t *prev)
48784885
{
4879-
ngx_pool_cleanup_t *cln;
4886+
ngx_uint_t preserve;
4887+
4888+
if (conf->ssl_protocols == 0
4889+
&& conf->ssl_ciphers.data == NULL
4890+
&& conf->upstream.ssl_certificate == NGX_CONF_UNSET_PTR
4891+
&& conf->upstream.ssl_certificate_key == NGX_CONF_UNSET_PTR
4892+
&& conf->upstream.ssl_passwords == NGX_CONF_UNSET_PTR
4893+
&& conf->upstream.ssl_verify == NGX_CONF_UNSET
4894+
&& conf->ssl_verify_depth == NGX_CONF_UNSET_UINT
4895+
&& conf->ssl_trusted_certificate.data == NULL
4896+
&& conf->ssl_crl.data == NULL
4897+
&& conf->upstream.ssl_session_reuse == NGX_CONF_UNSET
4898+
&& conf->ssl_conf_commands == NGX_CONF_UNSET_PTR)
4899+
{
4900+
if (prev->upstream.ssl) {
4901+
conf->upstream.ssl = prev->upstream.ssl;
4902+
return NGX_OK;
4903+
}
48804904

4881-
glcf->upstream.ssl = ngx_pcalloc(cf->pool, sizeof(ngx_ssl_t));
4882-
if (glcf->upstream.ssl == NULL) {
4905+
preserve = 1;
4906+
4907+
} else {
4908+
preserve = 0;
4909+
}
4910+
4911+
conf->upstream.ssl = ngx_pcalloc(cf->pool, sizeof(ngx_ssl_t));
4912+
if (conf->upstream.ssl == NULL) {
48834913
return NGX_ERROR;
48844914
}
48854915

4886-
glcf->upstream.ssl->log = cf->log;
4916+
conf->upstream.ssl->log = cf->log;
4917+
4918+
/*
4919+
* special handling to preserve conf->upstream.ssl
4920+
* in the "http" section to inherit it to all servers
4921+
*/
4922+
4923+
if (preserve) {
4924+
prev->upstream.ssl = conf->upstream.ssl;
4925+
}
4926+
4927+
return NGX_OK;
4928+
}
4929+
4930+
4931+
static ngx_int_t
4932+
ngx_http_grpc_set_ssl(ngx_conf_t *cf, ngx_http_grpc_loc_conf_t *glcf)
4933+
{
4934+
ngx_pool_cleanup_t *cln;
4935+
4936+
if (glcf->upstream.ssl->ctx) {
4937+
return NGX_OK;
4938+
}
48874939

48884940
if (ngx_ssl_create(glcf->upstream.ssl, glcf->ssl_protocols, NULL)
48894941
!= NGX_OK)

0 commit comments

Comments
 (0)