diff options
| author | Zhidao HONG <z.hong@f5.com> | 2025-07-15 15:35:39 +0000 |
|---|---|---|
| committer | Roman Arutyunyan <arutyunyan.roman@gmail.com> | 2025-12-08 07:49:16 +0400 |
| commit | 9bf758ea4d5db1101296cc111f6d782045148727 (patch) | |
| tree | fd9b351bae0e35ddeb518be9dd87811b999a9241 /src/http/modules/ngx_http_proxy_module.c | |
| parent | 90a4fc793527b67678fd48b2692be09f30d8ffcf (diff) | |
| download | nginx-9bf758ea4d5db1101296cc111f6d782045148727.tar.gz nginx-9bf758ea4d5db1101296cc111f6d782045148727.tar.bz2 | |
Proxy: added HTTP/2 proxy module.
The module allows to use HTTP/2 protocol for proxying.
HTTP/2 proxying is enabled by specifying "proxy_http_version 2".
Example:
server {
listen 8000;
location / {
proxy_http_version 2;
proxy_pass https://127.0.0.1:8443;
}
}
server {
listen 8443 ssl;
http2 on;
ssl_certificate certs/example.com.crt;
ssl_certificate_key certs/example.com.key;
location / {
return 200 foo;
}
}
Diffstat (limited to 'src/http/modules/ngx_http_proxy_module.c')
| -rw-r--r-- | src/http/modules/ngx_http_proxy_module.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c index 9f40c2193..7897b3f4b 100644 --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -198,6 +198,9 @@ static ngx_conf_post_t ngx_http_proxy_ssl_conf_command_post = static ngx_conf_enum_t ngx_http_proxy_http_version[] = { { ngx_string("1.0"), NGX_HTTP_VERSION_10 }, { ngx_string("1.1"), NGX_HTTP_VERSION_11 }, +#if (NGX_HTTP_V2) + { ngx_string("2"), NGX_HTTP_VERSION_20 }, +#endif { ngx_null_string, 0 } }; @@ -875,6 +878,14 @@ ngx_http_proxy_handler(ngx_http_request_t *r) ngx_http_proxy_main_conf_t *pmcf; #endif + plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module); + +#if (NGX_HTTP_V2) + if (plcf->http_version == NGX_HTTP_VERSION_20) { + return ngx_http_proxy_v2_handler(r); + } +#endif + if (ngx_http_upstream_create(r) != NGX_OK) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } @@ -888,8 +899,6 @@ ngx_http_proxy_handler(ngx_http_request_t *r) ngx_http_set_ctx(r, ctx, ngx_http_proxy_module); - plcf = ngx_http_get_module_loc_conf(r, ngx_http_proxy_module); - u = r->upstream; if (plcf->proxy_lengths == NULL) { |
