summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_upstream.h (follow)
AgeCommit message (Collapse)AuthorFilesLines
2022-06-07Upstream: fixed X-Accel-Expires/Cache-Control/Expires handling.Maxim Dounin1-0/+2
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.
2022-05-30Upstream: duplicate headers ignored or properly linked.Maxim Dounin1-0/+1
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.
2022-05-30Upstream: simplified Accept-Ranges handling.Maxim Dounin1-1/+0
The u->headers_in.accept_ranges field is not used anywhere and hence removed.
2022-05-30Upstream: simplified Content-Encoding handling.Maxim Dounin1-4/+0
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).
2022-05-30Reworked multi headers to use linked lists.Maxim Dounin1-2/+2
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.
2021-05-06Upstream: variables support in certificates.Maxim Dounin1-0/+4
2020-07-06FastCGI: protection from responses with wrong length.Maxim Dounin1-0/+1
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.
2020-07-06Upstream: drop extra data sent by upstream.Maxim Dounin1-0/+2
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).
2018-12-13Upstream: implemented $upstream_bytes_sent.Ruslan Ermilov1-0/+1
2018-11-21Upstream: revised upstream response time variables.Vladimir Homutov1-0/+2
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.
2018-11-21Upstream: removed unused ngx_http_upstream_t.timeout field.Vladimir Homutov1-2/+0
2018-10-03Upstream: proxy_socket_keepalive and friends.Vladimir Homutov1-0/+1
The directives enable the use of the SO_KEEPALIVE option on upstream connections. By default, the value is left unchanged.
2018-03-17Upstream: u->conf->preserve_output flag.Maxim Dounin1-0/+1
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.
2018-03-17Upstream: u->request_body_blocked flag.Maxim Dounin1-0/+1
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.
2018-03-17Upstream: trailers support, u->conf->pass_trailers flag.Maxim Dounin1-0/+2
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.
2018-02-22Modules compatibility: additional upstream metrics.Vladimir Homutov1-0/+1
2017-09-22Modules compatibility: down flag promoted to a bitmask.Ruslan Ermilov1-1/+1
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.
2017-03-24Upstream: allow recovery from "429 Too Many Requests" response.Piotr Sikora1-5/+7
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>
2017-02-10Upstream: proxy_cache_background_update and friends.Roman Arutyunyan1-0/+1
The directives enable cache updates in subrequests.
2017-01-31Variables: generic prefix variables.Dmitry Volyntsev1-5/+0
2017-01-26Upstream: removed unused bl_time and bl_state fields.Maxim Dounin1-3/+0
2017-01-24Upstream: removed unused ngx_http_upstream_conf_t.timeout field.Thibault Charbonnier1-1/+0
2017-01-25Upstream: removed compatibility shims from ngx_http_upstream_t.Vladimir Homutov1-3/+0
The type is no longer modified in NGINX Plus.
2016-11-02Cache: proxy_cache_max_range_offset and friends.Dmitry Volyntsev1-0/+2
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.
2016-10-17Upstream: removed ngx_http_upstream_srv_conf_t.default_port.Ruslan Ermilov1-1/+0
This is an API change.
2016-10-31Upstream: added the ngx_http_upstream_resolved_t.name field.Ruslan Ermilov1-0/+1
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.
2016-10-10Modules compatibility: compatibility with NGX_HTTP_SSL.Maxim Dounin1-2/+2
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.
2016-09-29Introduced the NGX_COMPAT macro.Ruslan Ermilov1-0/+9
When enabled, some structures are padded to be size compatible with their NGINX Plus versions.
2016-09-29Modules compatibility: cache purge fields.Maxim Dounin1-0/+1
2016-09-29Modules compatibility: slow start fields.Maxim Dounin1-0/+1
2016-09-22Upstream: max_conns.Ruslan Ermilov1-0/+2
2016-09-22Upstream: introduced u->upstream.Maxim Dounin1-0/+1
It holds upstream{} block configuration, including ones selected via run-time lookup using variables.
2016-08-10Upstream: the $upstream_bytes_received variable.Vladimir Homutov1-0/+1
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.
2015-12-18Upstream: the "transparent" parameter of proxy_bind and friends.Roman Arutyunyan1-0/+3
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;
2016-03-28Upstream: proxy_next_upstream non_idempotent.Maxim Dounin1-0/+1
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".
2016-03-23Resolver: added support for SRV records.Dmitry Volyntsev1-1/+1
2015-12-17Upstream: don't keep connections on early responses (ticket #669).Maxim Dounin1-0/+1
2015-11-11Upstream: proxy_cache_convert_head directive.Roman Arutyunyan1-0/+1
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.
2015-05-16Upstream: $upstream_connect_time.Ruslan Ermilov1-0/+1
The variable keeps time spent on establishing a connection with the upstream server.
2015-05-16Upstream: times to obtain header/response are stored as ngx_msec_t.Ruslan Ermilov1-4/+2
2015-04-14Upstream: the "zone" directive.Ruslan Ermilov1-0/+4
Upstreams with the "zone" directive are kept in shared memory, with a consistent view of all worker processes.
2015-03-23Request body: unbuffered reading.Maxim Dounin1-0/+1
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.
2015-01-14Upstream: $upstream_header_time variable.Vladimir Homutov1-0/+2
Keeps time spent on obtaining the header from an upstream server. The value is formatted similar to the $upstream_response_time variable.
2014-12-22Upstream: added variables support to proxy_cache and friends.Valentin Bartenev1-0/+4
2014-12-22Upstream: refactored proxy_cache and friends.Valentin Bartenev1-1/+4
The configuration handling code has changed to look similar to the proxy_store directive and friends. This simplifies adding variable support in the following patch. No functional changes.
2014-11-18Cache: proxy_cache_lock_age and friends.Roman Arutyunyan1-0/+1
Once this age is reached, the cache lock is discarded and another request can acquire the lock. Requests which failed to acquire the lock are not allowed to cache the response.
2014-10-28Upstream: proxy_limit_rate and friends.Roman Arutyunyan1-0/+1
The directives limit the upstream read rate. For example, "proxy_limit_rate 42" limits proxy upstream read rate to 42 bytes per second.
2014-10-27Cache: disable caching of responses with Vary (ticket #118).Maxim Dounin1-0/+2
The "proxy_ignore_header" directive now undersands the "Vary" parameter to ignore the header as needed.
2014-10-14Upstream: proxy_force_ranges and friends.Roman Arutyunyan1-0/+1
The directives enable byte ranges for both cached and uncached responses regardless of backend headers.
2014-09-12Upstream: limited next_upstream time and tries (ticket #544).Roman Arutyunyan1-0/+2
The new directives {proxy,fastcgi,scgi,uwsgi,memcached}_next_upstream_tries and {proxy,fastcgi,scgi,uwsgi,memcached}_next_upstream_timeout limit the number of upstreams tried and the maximum time spent for these tries when searching for a valid upstream.