comparison src/http/v2/ngx_http_v2_module.c @ 9119:08ef02ad5c54

HTTP/2: "http2" directive. The directive enables HTTP/2 in the current server. The previous way to enable HTTP/2 via "listen ... http2" is now deprecated. The new approach allows to share HTTP/2 and HTTP/0.9-1.1 on the same port. For SSL connections, HTTP/2 is now selected by ALPN callback based on whether the protocol is enabled in the virtual server chosen by SNI. This however only works since OpenSSL 1.0.2h, where ALPN callback is invoked after SNI callback. For older versions of OpenSSL, HTTP/2 is enabled based on the default virtual server configuration. For plain TCP connections, HTTP/2 is now auto-detected by HTTP/2 preface, if HTTP/2 is enabled in the default virtual server. If preface is not matched, HTTP/0.9-1.1 is assumed.
author Roman Arutyunyan <arut@nginx.com>
date Tue, 16 May 2023 16:30:08 +0400
parents 827202ca1269
children 262c01782566
comparison
equal deleted inserted replaced
9118:b4a57278bf24 9119:08ef02ad5c54
72 static ngx_conf_post_t ngx_http_v2_chunk_size_post = 72 static ngx_conf_post_t ngx_http_v2_chunk_size_post =
73 { ngx_http_v2_chunk_size }; 73 { ngx_http_v2_chunk_size };
74 74
75 75
76 static ngx_command_t ngx_http_v2_commands[] = { 76 static ngx_command_t ngx_http_v2_commands[] = {
77
78 { ngx_string("http2"),
79 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
80 ngx_conf_set_flag_slot,
81 NGX_HTTP_SRV_CONF_OFFSET,
82 offsetof(ngx_http_v2_srv_conf_t, enable),
83 NULL },
77 84
78 { ngx_string("http2_recv_buffer_size"), 85 { ngx_string("http2_recv_buffer_size"),
79 NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1, 86 NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
80 ngx_conf_set_size_slot, 87 ngx_conf_set_size_slot,
81 NGX_HTTP_MAIN_CONF_OFFSET, 88 NGX_HTTP_MAIN_CONF_OFFSET,
312 h2scf = ngx_pcalloc(cf->pool, sizeof(ngx_http_v2_srv_conf_t)); 319 h2scf = ngx_pcalloc(cf->pool, sizeof(ngx_http_v2_srv_conf_t));
313 if (h2scf == NULL) { 320 if (h2scf == NULL) {
314 return NULL; 321 return NULL;
315 } 322 }
316 323
324 h2scf->enable = NGX_CONF_UNSET;
325
317 h2scf->pool_size = NGX_CONF_UNSET_SIZE; 326 h2scf->pool_size = NGX_CONF_UNSET_SIZE;
318 327
319 h2scf->concurrent_streams = NGX_CONF_UNSET_UINT; 328 h2scf->concurrent_streams = NGX_CONF_UNSET_UINT;
320 h2scf->concurrent_pushes = NGX_CONF_UNSET_UINT; 329 h2scf->concurrent_pushes = NGX_CONF_UNSET_UINT;
321 330
330 static char * 339 static char *
331 ngx_http_v2_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child) 340 ngx_http_v2_merge_srv_conf(ngx_conf_t *cf, void *parent, void *child)
332 { 341 {
333 ngx_http_v2_srv_conf_t *prev = parent; 342 ngx_http_v2_srv_conf_t *prev = parent;
334 ngx_http_v2_srv_conf_t *conf = child; 343 ngx_http_v2_srv_conf_t *conf = child;
344
345 ngx_conf_merge_value(conf->enable, prev->enable, 0);
335 346
336 ngx_conf_merge_size_value(conf->pool_size, prev->pool_size, 4096); 347 ngx_conf_merge_size_value(conf->pool_size, prev->pool_size, 4096);
337 348
338 ngx_conf_merge_uint_value(conf->concurrent_streams, 349 ngx_conf_merge_uint_value(conf->concurrent_streams,
339 prev->concurrent_streams, 128); 350 prev->concurrent_streams, 128);