summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_upstream.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2016-05-13Improved EPOLLRDHUP handling.Valentin Bartenev1-1/+5
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.
2015-12-18Upstream: the "transparent" parameter of proxy_bind and friends.Roman Arutyunyan1-1/+21
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-04-13Upstream: prepared proxy_bind to accept parameters.Roman Arutyunyan1-38/+44
In addition, errors occurred while setting bind address are no longer ignored.
2016-03-30Style.Ruslan Ermilov1-12/+12
2016-03-28Upstream: proxy_next_upstream non_idempotent.Maxim Dounin1-1/+7
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-28Upstream: cached connections now tested against next_upstream.Maxim Dounin1-49/+42
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".
2016-03-18Threads: writing via threads pools in event pipe.Maxim Dounin1-1/+116
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.
2016-03-16Style.Ruslan Ermilov1-4/+4
2016-03-08Upstream: avoid closing client connection in edge case.Justin Li1-0/+5
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.
2016-03-10Upstream: fixed "zero size buf" alerts with cache (ticket #918).Maxim Dounin1-1/+2
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.
2016-02-04Dynamic modules: changed ngx_modules to cycle->modules.Maxim Dounin1-5/+5
2016-01-11Upstream: fixed changing method on X-Accel-Redirect.Maxim Dounin1-0/+1
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.
2015-12-17Upstream: don't keep connections on early responses (ticket #669).Maxim Dounin1-0/+3
2015-12-09Fixed fastcgi_pass with UNIX socket and variables (ticket #855).Ruslan Ermilov1-1/+3
This was broken in a93345ee8f52 (1.9.8).
2015-12-07Upstream: fill r->headers_out.content_range from upstream response.Roman Arutyunyan1-0/+5
2015-12-02Style.Maxim Dounin1-1/+1
2015-11-06Style: unified request method checks.Ruslan Ermilov1-1/+1
2015-11-21Upstream: fixed "no port" detection in evaluated upstreams.Ruslan Ermilov1-2/+10
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.
2015-11-11Upstream: proxy_cache_convert_head directive.Roman Arutyunyan1-1/+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-09-11The HTTP/2 implementation (RFC 7240, 7241).Valentin Bartenev1-4/+4
The SPDY support is removed, as it's incompatible with the new module.
2015-09-03Upstream: fixed cache send error handling.Roman Arutyunyan1-11/+14
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).
2015-06-11Moved ngx_http_parse_time() to core, renamed accordingly.Maxim Dounin1-3/+3
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.
2015-05-16Upstream: $upstream_connect_time.Ruslan Ermilov1-1/+13
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-26/+11
2015-04-22Removed the obsolete aio module.Ruslan Ermilov1-1/+1
2015-04-07Upstream: abbreviated SSL handshake may interact badly with Nagle.Ruslan Ermilov1-1/+25
2015-03-23Request body: unbuffered reading.Maxim Dounin1-14/+171
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-03-20Removed ngx_connection_t.lock.Ruslan Ermilov1-3/+0
2015-03-04Renamed NGX_THREADS to NGX_OLD_THREADS because of deprecation.Ruslan Ermilov1-1/+1
It's mostly dead code and the original idea of worker threads has been rejected.
2015-03-03Style.Maxim Dounin1-2/+2
Noted by Ruslan Ermilov.
2015-03-02Upstream: upstream argument in ngx_http_upstream_process_request().Maxim Dounin1-6/+6
In case of filter finalization, r->upstream might be changed during the ngx_event_pipe() call. Added an argument to preserve it while calling the ngx_http_upstream_process_request() function.
2015-03-02Upstream: avoid duplicate finalization.Maxim Dounin1-3/+7
A request may be already finalized when ngx_http_upstream_finalize_request() is called, due to filter finalization: after filter finalization upstream can be finalized via ngx_http_upstream_cleanup(), either from ngx_http_terminate_request(), or because a new request was initiated to an upstream. Then the upstream code will see an error returned from the filter chain and will call the ngx_http_upstream_finalize_request() function again. To prevent corruption of various upstream data in this situation, make sure to do nothing but merely call ngx_http_finalize_request(). Prodded by Yichun Zhang, for details see the thread at http://nginx.org/pipermail/nginx-devel/2015-February/006539.html.
2015-03-02Cache: do not inherit last_modified and etag from stale response.Roman Arutyunyan1-0/+7
When replacing a stale cache entry, its last_modified and etag could be inherited from the old entry if the response code is not 200 or 206. Moreover, etag could be inherited with any response code if it's missing in the new response. As a result, the cache entry is left with invalid last_modified or etag which could lead to broken revalidation. For example, when a file is deleted from backend, its last_modified is copied to the new 404 cache entry and is used later for revalidation. Once the old file appears again with its original timestamp, revalidation succeeds and the cached 404 response is sent to client instead of the file. The problem appeared with etags in 44b9ab7752e3 (1.7.3) and affected last_modified in 1573fc7875fa (1.7.9).
2015-01-22Upstream: detect port absence in fastcgi_pass with IP literal.Ruslan Ermilov1-1/+1
If fastcgi_pass (or any look-alike that doesn't imply a default port) is specified as an IP literal (as opposed to a hostname), port absence was not detected at configuration time and could result in EADDRNOTAVAIL at run time. Fixed this in such a way that configs like http { server { location / { fastcgi_pass 127.0.0.1; } } upstream 127.0.0.1 { server 10.0.0.1:12345; } } still work. That is, port absence check is delayed until after we make sure there's no explicit upstream with such a name.
2015-02-02Cache: added temp_path to file cache.Roman Arutyunyan1-4/+2
If use_temp_path is set to off, a subdirectory "temp" is created in the cache directory. It's used instead of proxy_temp_path and friends for caching upstream response.
2015-01-14Upstream: $upstream_header_time variable.Vladimir Homutov1-2/+22
Keeps time spent on obtaining the header from an upstream server. The value is formatted similar to the $upstream_response_time variable.
2014-12-26Upstream: use_temp_path parameter of proxy_cache_path and friends.Valentin Bartenev1-0/+8
When set to "off", temporary files for cacheable responses will be stored inside cache directory.
2014-12-26Cache: update variant while setting header.Valentin Bartenev1-1/+4
Some parts of code related to handling variants of a resource moved into a separate function that is called earlier. This allows to use cache file name as a prefix for temporary file in the following patch.
2014-12-22Upstream: added variables support to proxy_cache and friends.Valentin Bartenev1-3/+55
2014-12-22Upstream: preset some cache configuration when bypassing.Valentin Bartenev1-9/+7
No functional changes.
2014-12-22Upstream: refactored proxy_cache and friends.Valentin Bartenev1-3/+3
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-12-22Upstream: simplified proxy_store and friends configuration code.Valentin Bartenev1-1/+1
This changes internal API related to handling of the "store" flag in ngx_http_upstream_conf_t. Previously, a non-null value of "store_lengths" was enough to enable store functionality with custom path. Now, the "store" flag is also required to be set. No functional changes.
2014-11-26Cache: send conditional requests only for cached 200/206 responses.Piotr Sikora1-3/+8
RFC7232 says: The 304 (Not Modified) status code indicates that a conditional GET or HEAD request has been received and would have resulted in a 200 (OK) response if it were not for the fact that the condition evaluated to false. which means that there is no reason to send requests with "If-None-Match" and/or "If-Modified-Since" headers for responses cached with other status codes. Also, sending conditional requests for responses cached with other status codes could result in a strange behavior, e.g. upstream server returning 304 Not Modified for cached 404 Not Found responses, etc. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
2014-12-02Upstream: improved subrequest logging.Maxim Dounin1-3/+8
To ensure proper logging make sure to set current_request in all event handlers, including resolve, ssl handshake, cache lock wait timer and aio read handlers. A macro ngx_http_set_log_request() introduced to simplify this.
2014-11-18Cache: add support for Cache-Control's s-maxage response directive.Piotr Sikora1-8/+14
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
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-11-04Upstream: support named location for X-Accel-Redirect.Toshikuni Fukaya1-9/+16
2014-10-27Upstream: limited next_upstream time and tries when resolving DNS.Gu Feng1-0/+8
When got multiple upstream IP addresses using DNS resolving, the number of upstreams tries and the maxinum time spent for these tries were not affected. This patch fixed it.
2014-10-28Upstream: proxy_limit_rate and friends.Roman Arutyunyan1-4/+46
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: hash of Vary headers now stored in cache.Maxim Dounin1-1/+11
To cache responses with Vary, we now calculate hash of headers listed in Vary, and return the response from cache only if new request headers match. As of now, only one variant of the same resource can be stored in cache.