diff options
| author | Zhidao HONG <z.hong@f5.com> | 2025-07-15 14:54:21 +0000 |
|---|---|---|
| committer | Roman Arutyunyan <arutyunyan.roman@gmail.com> | 2025-12-08 07:49:16 +0400 |
| commit | b8492d9c25c34c87419d2ad118fa812fd72da27c (patch) | |
| tree | ef64a4bbb7c45488bb4ea6d5ab66df9a3e57a2b6 | |
| parent | f405ef11fde6ed749318a844c010ce97483a8f98 (diff) | |
| download | nginx-b8492d9c25c34c87419d2ad118fa812fd72da27c.tar.gz nginx-b8492d9c25c34c87419d2ad118fa812fd72da27c.tar.bz2 | |
Upstream: add support for connection level ALPN protocol negotiation.
This commit is prepared for HTTP/2 and HTTP/3 support.
The ALPN protocol is now set per-connection in
ngx_http_upstream_ssl_init_connection(), allowing proper protocol negotiation
for each individual upstream connection regardless of SSL context sharing.
| -rw-r--r-- | src/http/ngx_http_upstream.c | 17 | ||||
| -rw-r--r-- | src/http/ngx_http_upstream.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index 66163548a..2e4b2b48f 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -1771,6 +1771,23 @@ ngx_http_upstream_ssl_init_connection(ngx_http_request_t *r, } } +#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation + + if (u->ssl_alpn_protocol.len) { + if (SSL_set_alpn_protos(c->ssl->connection, u->ssl_alpn_protocol.data, + u->ssl_alpn_protocol.len) + != 0) + { + ngx_ssl_error(NGX_LOG_ERR, c->log, 0, + "SSL_set_alpn_protos() failed"); + ngx_http_upstream_finalize_request(r, u, + NGX_HTTP_INTERNAL_SERVER_ERROR); + return; + } + } + +#endif + if (u->conf->ssl_session_reuse) { c->ssl->save_session = ngx_http_upstream_ssl_save_session; diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h index 64d70cfea..3afe6e8f9 100644 --- a/src/http/ngx_http_upstream.h +++ b/src/http/ngx_http_upstream.h @@ -390,6 +390,7 @@ struct ngx_http_upstream_s { #if (NGX_HTTP_SSL || NGX_COMPAT) ngx_str_t ssl_name; + ngx_str_t ssl_alpn_protocol; #endif ngx_http_cleanup_pt *cleanup; |
