aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_upstream.h
Commit message (Collapse)AuthorAge
* Upstream: fixed passwords support for dynamic certificates.Sergey Kandaurov2025-04-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Passwords were not preserved in optimized SSL contexts, the bug had appeared in d791b4aab (1.23.1), as in the following configuration: server { proxy_ssl_password_file password; proxy_ssl_certificate $ssl_server_name.crt; proxy_ssl_certificate_key $ssl_server_name.key; location /original/ { proxy_pass https://u1/; } location /optimized/ { proxy_pass https://u2/; } } The fix is to always preserve passwords, by copying to the configuration pool, if dynamic certificates are used. This is done as part of merging "ssl_passwords" configuration. To minimize the number of copies, a preserved version is then used for inheritance. A notable exception is inheritance of preserved empty passwords to the context with statically configured certificates: server { proxy_ssl_certificate $ssl_server_name.crt; proxy_ssl_certificate_key $ssl_server_name.key; location / { proxy_pass ...; proxy_ssl_certificate example.com.crt; proxy_ssl_certificate_key example.com.key; } } In this case, an unmodified version (NULL) of empty passwords is set, to allow reading them from the password prompt on nginx startup. As an additional optimization, a preserved instance of inherited configured passwords is set to the previous level, to inherit it to other contexts: server { proxy_ssl_password_file password; location /1/ { proxy_pass https://u1/; proxy_ssl_certificate $ssl_server_name.crt; proxy_ssl_certificate_key $ssl_server_name.key; } location /2/ { proxy_pass https://u2/; proxy_ssl_certificate $ssl_server_name.crt; proxy_ssl_certificate_key $ssl_server_name.key; } }
* Upstream: caching certificates and certificate keys with variables.Sergey Kandaurov2025-01-17
| | | | | | Caching is enabled with proxy_ssl_certificate_cache and friends. Co-authored-by: Aleksei Bavshin <a.bavshin@nginx.com>
* Upstream: construct upstream peers from DNS SRV records.Dmitry Volyntsev2024-11-07
|
* Upstream: re-resolvable servers.Ruslan Ermilov2024-11-07
| | | | | | | | | | | | | | | | | | | | | | | | | Specifying the upstream server by a hostname together with the "resolve" parameter will make the hostname to be periodically resolved, and upstream servers added/removed as necessary. This requires a "resolver" at the "http" configuration block. The "resolver_timeout" parameter also affects when the failed DNS requests will be attempted again. Responses with NXDOMAIN will be attempted again in 10 seconds. Upstream has a configuration generation number that is incremented each time servers are added/removed to the primary/backup list. This number is remembered by the peer.init method, and if peer.get detects a change in configuration, it returns NGX_BUSY. Each server has a reference counter. It is incremented by peer.get and decremented by peer.free. When a server is removed, it is removed from the list of servers and is marked as "zombie". The memory allocated by a zombie peer is freed only when its reference count becomes zero. Co-authored-by: Roman Arutyunyan <arut@nginx.com> Co-authored-by: Sergey Kandaurov <pluknet@nginx.com> Co-authored-by: Vladimir Homutov <vl@nginx.com>
* Proxy: proxy_pass_trailers directive.Sergey Kandaurov2024-09-13
| | | | The directive allows to pass upstream response trailers to client.
* Upstream: variables support in proxy_limit_rate and friends.J Carter2023-11-25
|
* Upstream: fixed X-Accel-Expires/Cache-Control/Expires handling.Maxim Dounin2022-06-07
| | | | | | | | | | | | | | | | | | | | | | Previously, if caching was disabled due to Expires in the past, nginx failed to cache the response even if it was cacheable as per subsequently parsed Cache-Control header (ticket #964). Similarly, if caching was disabled due to Expires in the past, "Cache-Control: no-cache" or "Cache-Control: max-age=0", caching was not used if it was cacheable as per subsequently parsed X-Accel-Expires header. Fix is to avoid disabling caching immediately after parsing Expires in the past or Cache-Control, but rather set flags which are later checked by ngx_http_upstream_process_headers() (and cleared by "Cache-Control: max-age" and X-Accel-Expires). Additionally, now X-Accel-Expires does not prevent parsing of cache control extensions, notably stale-while-revalidate and stale-if-error. This ensures that order of the X-Accel-Expires and Cache-Control headers is not important. Prodded by Vadim Fedorenko and Yugo Horie.
* Upstream: duplicate headers ignored or properly linked.Maxim Dounin2022-05-30
| | | | | | | | | Most of the known duplicate upstream response headers are now ignored with a warning. If syntax permits multiple headers, these are now properly linked to the lists, notably Vary and WWW-Authenticate. This makes it possible to further handle such lists where it makes sense.
* Upstream: simplified Accept-Ranges handling.Maxim Dounin2022-05-30
| | | | The u->headers_in.accept_ranges field is not used anywhere and hence removed.
* Upstream: simplified Content-Encoding handling.Maxim Dounin2022-05-30
| | | | | | | | | | | | | | | Since introduction of offset handling in ngx_http_upstream_copy_header_line() in revision 573:58475592100c, the ngx_http_upstream_copy_content_encoding() function is no longer needed, as its behaviour is exactly equivalent to ngx_http_upstream_copy_header_line() with appropriate offset. As such, the ngx_http_upstream_copy_content_encoding() function was removed. Further, the u->headers_in.content_encoding field is not used anywhere, so it was removed as well. Further, Content-Encoding handling no longer depends on NGX_HTTP_GZIP, as it can be used even without any gzip handling compiled in (for example, in the charset filter).
* Reworked multi headers to use linked lists.Maxim Dounin2022-05-30
| | | | | | | | | | | | | | | | | Multi headers are now using linked lists instead of arrays. Notably, the following fields were changed: r->headers_in.cookies (renamed to r->headers_in.cookie), r->headers_in.x_forwarded_for, r->headers_out.cache_control, r->headers_out.link, u->headers_in.cache_control u->headers_in.cookies (renamed to u->headers_in.set_cookie). The r->headers_in.cookies and u->headers_in.cookies fields were renamed to r->headers_in.cookie and u->headers_in.set_cookie to match header names. The ngx_http_parse_multi_header_lines() and ngx_http_parse_set_cookie_lines() functions were changed accordingly. With this change, multi headers are now essentially equivalent to normal headers, and following changes will further make them equivalent.
* Upstream: variables support in certificates.Maxim Dounin2021-05-06
|
* FastCGI: protection from responses with wrong length.Maxim Dounin2020-07-06
| | | | | | | | | | | | | | | Previous behaviour was to pass everything to the client, but this seems to be suboptimal and causes issues (ticket #1695). Fix is to drop extra data instead, as it naturally happens in most clients. Additionally, we now also issue a warning if the response is too short, and make sure the fact it is truncated is propagated to the client. The u->error flag is introduced to make it possible to propagate the error to the client in case of unbuffered proxying. For responses to HEAD requests there is an exception: we do allow both responses without body and responses with body matching the Content-Length header.
* Upstream: drop extra data sent by upstream.Maxim Dounin2020-07-06
| | | | | | | | | | | | | | | | | | Previous behaviour was to pass everything to the client, but this seems to be suboptimal and causes issues (ticket #1695). Fix is to drop extra data instead, as it naturally happens in most clients. This change covers generic buffered and unbuffered filters as used in the scgi and uwsgi modules. Appropriate input filter init handlers are provided by the scgi and uwsgi modules to set corresponding lengths. Note that for responses to HEAD requests there is an exception: we do allow any response length. This is because responses to HEAD requests might be actual full responses, and it is up to nginx to remove the response body. If caching is enabled, only full responses matching the Content-Length header will be cached (see b779728b180c).
* Upstream: implemented $upstream_bytes_sent.Ruslan Ermilov2018-12-13
|
* Upstream: revised upstream response time variables.Vladimir Homutov2018-11-21
| | | | | | | | | Variables now do not depend on presence of the HTTP status code in response. If the corresponding event occurred, variables contain time between request creation and the event, and "-" otherwise. Previously, intermediate value of the $upstream_response_time variable held unix timestamp.
* Upstream: removed unused ngx_http_upstream_t.timeout field.Vladimir Homutov2018-11-21
|
* Upstream: proxy_socket_keepalive and friends.Vladimir Homutov2018-10-03
| | | | | The directives enable the use of the SO_KEEPALIVE option on upstream connections. By default, the value is left unchanged.
* Upstream: u->conf->preserve_output flag.Maxim Dounin2018-03-17
| | | | | | | The flag can be used to continue sending request body even after we've got a response from the backend. In particular, this is needed for gRPC proxying of bidirectional streaming RPCs, and also to send control frames in other forms of RPCs.
* Upstream: u->request_body_blocked flag.Maxim Dounin2018-03-17
| | | | | | | | The flag indicates whether last ngx_output_chain() returned NGX_AGAIN or not. If the flag is set, we arm the u->conf->send_timeout timer. The flag complements c->write->ready test, and allows to stop sending the request body in an output filter due to protocol-specific flow control.
* Upstream: trailers support, u->conf->pass_trailers flag.Maxim Dounin2018-03-17
| | | | | | | | | | Basic trailer headers support allows one to access response trailers via the $upstream_trailer_* variables. Additionally, the u->conf->pass_trailers flag was introduced. When the flag is set, trailer headers from the upstream response are passed to the client. Like normal headers, trailer headers will be hidden if present in u->conf->hide_headers_hash.
* Modules compatibility: additional upstream metrics.Vladimir Homutov2018-02-22
|
* Modules compatibility: down flag promoted to a bitmask.Ruslan Ermilov2017-09-22
| | | | | | It is to be used as a bitmask with various bits set/reset when appropriate. 63b8b157b776 made a similar change to ngx_http_upstream_rr_peer_t.down and ngx_stream_upstream_rr_peer_t.down.
* Upstream: allow recovery from "429 Too Many Requests" response.Piotr Sikora2017-03-24
| | | | | | | | This change adds "http_429" parameter to "proxy_next_upstream" for retrying rate-limited requests, and to "proxy_cache_use_stale" for serving stale cached responses after being rate-limited. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
* Upstream: proxy_cache_background_update and friends.Roman Arutyunyan2017-02-10
| | | | The directives enable cache updates in subrequests.
* Variables: generic prefix variables.Dmitry Volyntsev2017-01-31
|
* Upstream: removed unused bl_time and bl_state fields.Maxim Dounin2017-01-26
|
* Upstream: removed unused ngx_http_upstream_conf_t.timeout field.Thibault Charbonnier2017-01-24
|
* Upstream: removed compatibility shims from ngx_http_upstream_t.Vladimir Homutov2017-01-25
| | | | The type is no longer modified in NGINX Plus.
* Cache: proxy_cache_max_range_offset and friends.Dmitry Volyntsev2016-11-02
| | | | | | It configures a threshold in bytes, above which client range requests are not cached. In such a case the client's Range header is passed directly to a proxied server.
* Upstream: removed ngx_http_upstream_srv_conf_t.default_port.Ruslan Ermilov2016-10-17
| | | | This is an API change.
* Upstream: added the ngx_http_upstream_resolved_t.name field.Ruslan Ermilov2016-10-31
| | | | | | | | | | | | | | | | | | | | | | This fixes inconsistency in what is stored in the "host" field. Normally it would contain the "host" part of the parsed URL (e.g., proxy_pass with variables), but for the case of an implicit upstream specified with literal address it contained the text representation of the socket address (that is, host including port for IP). Now the "host" field always contains the "host" part of the URL, while the text representation of the socket address is stored in the newly added "name" field. The ngx_http_upstream_create_round_robin_peer() function was modified accordingly in a way to be compatible with the code that does not know about the new "name" field. The "stream" code was similarly modified except for not adding compatibility in ngx_stream_upstream_create_round_robin_peer(). This change is also a prerequisite for the next change.
* Modules compatibility: compatibility with NGX_HTTP_SSL.Maxim Dounin2016-10-10
| | | | | | | With this change it is now possible to load modules compiled without the "--with-http_ssl_module" configure option into nginx binary compiled with it, and vice versa (if a module doesn't use ssl-specific functions), assuming both use the "--with-compat" option.
* Introduced the NGX_COMPAT macro.Ruslan Ermilov2016-09-29
| | | | | When enabled, some structures are padded to be size compatible with their NGINX Plus versions.
* Modules compatibility: cache purge fields.Maxim Dounin2016-09-29
|
* Modules compatibility: slow start fields.Maxim Dounin2016-09-29
|
* Upstream: max_conns.Ruslan Ermilov2016-09-22
|
* Upstream: introduced u->upstream.Maxim Dounin2016-09-22
| | | | | It holds upstream{} block configuration, including ones selected via run-time lookup using variables.
* Upstream: the $upstream_bytes_received variable.Vladimir Homutov2016-08-10
| | | | | | Unlike $upstream_response_length that only counts the body size, the new variable also counts the size of response header and data received after switching protocols when proxying WebSockets.
* Upstream: the "transparent" parameter of proxy_bind and friends.Roman Arutyunyan2015-12-18
| | | | | | | | | | | This parameter lets binding the proxy connection to a non-local address. Upstream will see the connection as coming from that address. When used with $remote_addr, upstream will accept the connection from real client address. Example: proxy_bind $remote_addr transparent;
* Upstream: proxy_next_upstream non_idempotent.Maxim Dounin2016-03-28
| | | | | | | By default, requests with non-idempotent methods (POST, LOCK, PATCH) are no longer retried in case of errors if a request was already sent to a backend. Previous behaviour can be restored by using "proxy_next_upstream ... non_idempotent".
* Resolver: added support for SRV records.Dmitry Volyntsev2016-03-23
|
* Upstream: don't keep connections on early responses (ticket #669).Maxim Dounin2015-12-17
|
* Upstream: proxy_cache_convert_head directive.Roman Arutyunyan2015-11-11
| | | | | | The directive toggles conversion of HEAD to GET for cacheable proxy requests. When disabled, $request_method must be added to cache key for consistency. By default, HEAD is converted to GET as before.
* Upstream: $upstream_connect_time.Ruslan Ermilov2015-05-16
| | | | | The variable keeps time spent on establishing a connection with the upstream server.
* Upstream: times to obtain header/response are stored as ngx_msec_t.Ruslan Ermilov2015-05-16
|
* Upstream: the "zone" directive.Ruslan Ermilov2015-04-14
| | | | | Upstreams with the "zone" directive are kept in shared memory, with a consistent view of all worker processes.
* Request body: unbuffered reading.Maxim Dounin2015-03-23
| | | | | | | | | | | The r->request_body_no_buffering flag was introduced. It instructs client request body reading code to avoid reading the whole body, and to call post_handler early instead. The caller should use the ngx_http_read_unbuffered_request_body() function to read remaining parts of the body. Upstream module is now able to use this mode, if configured with the proxy_request_buffering directive.
* Upstream: $upstream_header_time variable.Vladimir Homutov2015-01-14
| | | | | Keeps time spent on obtaining the header from an upstream server. The value is formatted similar to the $upstream_response_time variable.
* Upstream: added variables support to proxy_cache and friends.Valentin Bartenev2014-12-22
|