proxy_http_version

The 'proxy_http_version' directive specifies the HTTP protocol version used when communicating with a proxied server.

Syntaxproxy_http_version 1.0 | 1.1;
Default1.1
Contexthttp, server, location
Arguments1

Description

The 'proxy_http_version' directive allows you to set the desired HTTP protocol version (such as HTTP/1.0 or HTTP/1.1) that NGINX should use when connecting to a backend server while proxying requests. The choice of protocol version can affect the behavior of the connection and optional features available, such as keep-alive connections, depending on the capabilities of the proxied server.

In the context of NGINX configuration, this directive can be specified in the 'http', 'server', or 'location' context, allowing for fine-grained control over specific areas of your configuration regarding how NGINX interacts with upstream servers. For example, when using HTTP/1.0, only a single request can be sent per connection without keep-alive, which may impact the performance of your application depending on how requests are handled.

The syntax for the directive is 'proxy_http_version <version>;' where <version> is the desired HTTP version (e.g., '1.0' or '1.1'). It's important to ensure that the server you are proxying to supports the specified HTTP version, otherwise you may encounter unexpected errors or degraded performance.

Config Example

location /api {
    proxy_pass http://backend;
    proxy_http_version 1.1;
}

Setting 'proxy_http_version' to '1.0' disables keep-alive connections by default.

Ensure the upstream server supports the selected HTTP version to avoid errors. Changing the version may alter the expected behavior of the connection.

← Back to all directives