aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_upstream.c
Commit message (Collapse)AuthorAge
...
* Upstream: proxy_cache_background_update and friends.Roman Arutyunyan2017-02-10
| | | | The directives enable cache updates in subrequests.
* Cache: support for stale-while-revalidate and stale-if-error.Roman Arutyunyan2016-12-22
| | | | | | | | Previously, there was no way to enable the proxy_cache_use_stale behavior by reading the backend response. Now, stale-while-revalidate and stale-if-error Cache-Control extensions (RFC 5861) are supported. They specify, how long a stale response can be used when a cache entry is being updated, or in case of an error.
* Variables: generic prefix variables.Dmitry Volyntsev2017-01-31
|
* Upstream: fixed cache corruption and socket leaks with aio_write.Maxim Dounin2017-01-20
| | | | | | | | | | | | | | | | | | | | | | | | | The ngx_event_pipe() function wasn't called on write events with wev->delayed set. As a result, threaded writing results weren't properly collected in ngx_event_pipe_write_to_downstream() when a write event was triggered for a completed write. Further, this wasn't detected, as p->aio was reset by a thread completion handler, and results were later collected in ngx_event_pipe_read_upstream() instead of scheduling a new write of additional data. If this happened on the last reading from an upstream, last part of the response was never written to the cache file. Similar problems might also happen in case of timeouts when writing to client, as this also results in ngx_event_pipe() not being called on write events. In this scenario socket leaks were observed. Fix is to check if p->writing is set in ngx_event_pipe_read_upstream(), and therefore collect results of previous write operations in case of read events as well, similar to how we do so in ngx_event_pipe_write_downstream(). This is enough to fix the wev->delayed case. Additionally, we now call ngx_event_pipe() from ngx_http_upstream_process_request() if there are uncollected write operations (p->writing and !p->aio). This also fixes the wev->timedout case.
* Fixed missing "Location" field with some relative redirects.Ruslan Ermilov2016-12-22
| | | | | Relative redirects did not work with directory redirects and auto redirects issued by nginx.
* Upstream: handling of upstream SSL handshake timeouts.Maxim Dounin2016-11-14
| | | | | Previously SSL handshake timeouts were not properly logged, and resulted in 502 errors instead of 504 (ticket #1126).
* Cache: prefix-based temporary files.Maxim Dounin2016-11-03
| | | | | | | | | | | On Linux, the rename syscall can be slow due to a global file system lock, acquired for the entire rename operation, unless both old and new files are in the same directory. To address this temporary files are now created in the same directory as the expected resulting cache file when using the "use_temp_path=off" parameter. This change mostly reverts 99639bfdfa2a and 3281de8142f5, restoring the behaviour as of a9138c35120d (with minor changes).
* Upstream: avoid holding a cache node with upgraded connections.Maxim Dounin2016-11-03
| | | | | | | | | Holding a cache node lock doesn't make sense as we can't use caching anyway, and results in "ignore long locked inactive cache entry" alerts if a node is locked for a long time. The same is done for unbuffered connections, as they can be alive for a long time as well.
* 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: don't consider default_port when matching upstreams.Ruslan Ermilov2016-10-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The only thing that default_port comparison did in the current code is prevented implicit upstreams to the same address/port from being aliased for http and https, e.g.: proxy_pass http://10.0.0.1:12345; proxy_pass https://10.0.0.1:12345; This is inconsistent because it doesn't work for a similar case with uswgi_pass: uwsgi_pass uwsgi://10.0.0.1:12345; uwsgi_pass suwsgi://10.0.0.1:12345; or with an explicit upstream: upstream u { server 10.0.0.1:12345; } proxy_pass http://u; proxy_pass https://u; Before c9059bd5445b, default_port comparison was needed to differentiate implicit upstreams in proxy_pass http://example.com; and proxy_pass https://example.com; as u->port was not set.
* Upstream: consistently initialize explicit upstreams.Ruslan Ermilov2016-10-17
| | | | | | | | | | | | | | | | | | | | When an upstream{} block follows a proxy_pass reference to it, such an upstream inherited port and default_port settings from proxy_pass. This was different from when they came in another order (see ticket #1059). Explicit upstreams should not have port and default_port in any case. This fixes the following case: server { location / { proxy_pass http://u; } ... } upstream u { server 127.0.0.1; } server { location / { proxy_pass https://u; } ... } but not the following: server { location / { proxy_pass http://u; } ... } server { location / { proxy_pass https://u; } ... } upstream u { server 127.0.0.1; }
* Upstream: do not unnecessarily create per-request upstreams.Ruslan Ermilov2016-10-31
| | | | | | | | | If proxy_pass (and friends) with variables evaluates an upstream specified with literal address, nginx always created a per-request upstream. Now, if there's a matching upstream specified in the configuration (either implicit or explicit), it will be used instead.
* SSL: compatibility with BoringSSL.Maxim Dounin2016-10-19
| | | | | | | | | BoringSSL changed SSL_set_tlsext_host_name() to be a real function with a (const char *) argument, so it now triggers a warning due to conversion from (u_char *). Added an explicit cast to silence the warning. Prodded by Piotr Sikora, Alessandro Ghedini.
* Upstream: hide_headers_hash handling at http level.Maxim Dounin2016-10-14
| | | | | | When headers to hide are set at the "http" level and not redefined in a server block, we now preserve compiled headers hash into the "http" section configuration to inherit this hash to all servers.
* Upstream: hide_headers_hash inherited regardless of cache settings.Maxim Dounin2016-10-14
| | | | | | | Dependency on cache settings existed prior to 2728c4e4a9ae (0.8.44) as Set-Cookie header was automatically hidden from responses when using cache. This is no longer the case, and hide_headers_hash can be safely inherited regardless of cache settings.
* 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.
* Fixed log levels of configuration parsing errors.Valentin Bartenev2016-09-20
| | | | | | All the errors that prevent loading configuration must be printed on the "emerg" log level. Previously, nginx might silently fail to load configuration in some cases as the default log level is "error".
* 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: support for port in proxy_bind and friends.Roman Arutyunyan2016-06-20
|
* Improved EPOLLRDHUP handling.Valentin Bartenev2016-05-13
| | | | | | | | | | | | | | | | | When it's known that the kernel supports EPOLLRDHUP, there is no need in additional recv() call to get EOF or error when the flag is absent in the event generated by the kernel. A special runtime test is done at startup to detect if EPOLLRDHUP is actually supported by the kernel because epoll_ctl() silently ignores unknown flags. With this knowledge it's now possible to drop the "ready" flag for partial read. Previously, the "ready" flag was kept until the recv() returned EOF or error. In particular, this change allows the lingering close heuristics (which relies on the "ready" flag state) to actually work on Linux, and not wait for more data in most cases. The "available" flag is now used in the read event with the semantics similar to the corresponding counter in kqueue.
* 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: prepared proxy_bind to accept parameters.Roman Arutyunyan2016-04-13
| | | | In addition, errors occurred while setting bind address are no longer ignored.
* Style.Ruslan Ermilov2016-03-30
|
* 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".
* Upstream: cached connections now tested against next_upstream.Maxim Dounin2016-03-28
| | | | | | | | Much like normal connections, cached connections are now tested against u->conf->next_upstream, and u->state->status is now always set. This allows to disable additional tries even with upstream keepalive by using "proxy_next_upstream off".
* Threads: writing via threads pools in event pipe.Maxim Dounin2016-03-18
| | | | | | | | | | | The "aio_write" directive is introduced, which enables use of aio for writing. Currently it is meaningful only with "aio threads". Note that aio operations can be done by both event pipe and output chain, so proper mapping between r->aio and p->aio is provided when calling ngx_event_pipe() and in output filter. In collaboration with Valentin Bartenev.
* Style.Ruslan Ermilov2016-03-16
|
* Upstream: avoid closing client connection in edge case.Justin Li2016-03-08
| | | | | | | | | | | | | | | | | | | | | | If proxy_cache is enabled, and proxy_no_cache tests true, it was previously possible for the client connection to be closed after a 304. The fix is to recheck r->header_only after the final cacheability is determined, and end the request if no longer cacheable. Example configuration: proxy_cache foo; proxy_cache_bypass 1; proxy_no_cache 1; If a client sends If-None-Match, and the upstream server returns 200 with a matching ETag, no body should be returned to the client. At the start of ngx_http_upstream_send_response proxy_no_cache is not yet tested, thus cacheable is still 1 and downstream_error is set. However, by the time the downstream_error check is done in process_request, proxy_no_cache has been tested and cacheable is set to 0. The client connection is then closed, regardless of keepalive.
* Upstream: fixed "zero size buf" alerts with cache (ticket #918).Maxim Dounin2016-03-10
| | | | | | | | | | | | | | | | If caching was used, "zero size buf in output" alerts might appear in logs if a client prematurely closed connection. Alerts appeared in the following situation: - writing to client returned an error, so event pipe drained all busy buffers leaving body output filters in an invalid state; - when upstream response was fully received, ngx_http_upstream_finalize_request() tried to flush all pending data. Fix is to avoid flushing body if p->downstream_error is set.
* Dynamic modules: changed ngx_modules to cycle->modules.Maxim Dounin2016-02-04
|
* Upstream: fixed changing method on X-Accel-Redirect.Maxim Dounin2016-01-11
| | | | | | | Previously, only r->method was changed, resulting in handling of a request as GET within nginx itself, but not in requests to proxied servers. See http://mailman.nginx.org/pipermail/nginx/2015-December/049518.html.
* Upstream: don't keep connections on early responses (ticket #669).Maxim Dounin2015-12-17
|
* Fixed fastcgi_pass with UNIX socket and variables (ticket #855).Ruslan Ermilov2015-12-09
| | | | This was broken in a93345ee8f52 (1.9.8).
* Upstream: fill r->headers_out.content_range from upstream response.Roman Arutyunyan2015-12-07
|
* Style.Maxim Dounin2015-12-02
|
* Style: unified request method checks.Ruslan Ermilov2015-11-06
|
* Upstream: fixed "no port" detection in evaluated upstreams.Ruslan Ermilov2015-11-21
| | | | | | If an upstream with variables evaluated to address without a port, then instead of a "no port in upstream" error an attempt was made to connect() which failed with EADDRNOTAVAIL.
* 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.
* The HTTP/2 implementation (RFC 7240, 7241).Valentin Bartenev2015-09-11
| | | | The SPDY support is removed, as it's incompatible with the new module.
* Upstream: fixed cache send error handling.Roman Arutyunyan2015-09-03
| | | | | | | | | The value of NGX_ERROR, returned from filter handlers, was treated as a generic upstream error and changed to NGX_HTTP_INTERNAL_SERVER_ERROR before calling ngx_http_finalize_request(). This resulted in "header already sent" alert if header was already sent in filter handlers. The problem appeared in 54e9b83d00f0 (1.7.5).
* Moved ngx_http_parse_time() to core, renamed accordingly.Maxim Dounin2015-06-11
| | | | | | | | | The function is now called ngx_parse_http_time(), and can be used by any code to parse HTTP-style date and time. In particular, it will be used for OCSP stapling. For compatibility, a macro to map ngx_http_parse_time() to the new name provided for a while.
* 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
|
* Removed the obsolete aio module.Ruslan Ermilov2015-04-22
|
* Upstream: abbreviated SSL handshake may interact badly with Nagle.Ruslan Ermilov2015-04-07
|
* 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.
* Removed ngx_connection_t.lock.Ruslan Ermilov2015-03-20
|
* Renamed NGX_THREADS to NGX_OLD_THREADS because of deprecation.Ruslan Ermilov2015-03-04
| | | | It's mostly dead code and the original idea of worker threads has been rejected.