aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_upstream.c
Commit message (Collapse)AuthorAge
...
* Style.Maxim Dounin2015-03-03
| | | | Noted by Ruslan Ermilov.
* Upstream: upstream argument in ngx_http_upstream_process_request().Maxim Dounin2015-03-02
| | | | | | 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.
* Upstream: avoid duplicate finalization.Maxim Dounin2015-03-02
| | | | | | | | | | | | | | | | 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.
* Cache: do not inherit last_modified and etag from stale response.Roman Arutyunyan2015-03-02
| | | | | | | | | | | | | | | | 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).
* Upstream: detect port absence in fastcgi_pass with IP literal.Ruslan Ermilov2015-01-22
| | | | | | | | | | | | | | | | | | | | | | | | 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.
* Cache: added temp_path to file cache.Roman Arutyunyan2015-02-02
| | | | | | 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.
* 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: use_temp_path parameter of proxy_cache_path and friends.Valentin Bartenev2014-12-26
| | | | | When set to "off", temporary files for cacheable responses will be stored inside cache directory.
* Cache: update variant while setting header.Valentin Bartenev2014-12-26
| | | | | | 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.
* Upstream: added variables support to proxy_cache and friends.Valentin Bartenev2014-12-22
|
* Upstream: preset some cache configuration when bypassing.Valentin Bartenev2014-12-22
| | | | No functional changes.
* Upstream: refactored proxy_cache and friends.Valentin Bartenev2014-12-22
| | | | | | | | 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.
* Upstream: simplified proxy_store and friends configuration code.Valentin Bartenev2014-12-22
| | | | | | | | | 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.
* Cache: send conditional requests only for cached 200/206 responses.Piotr Sikora2014-11-26
| | | | | | | | | | | | | | | | | | | 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>
* Upstream: improved subrequest logging.Maxim Dounin2014-12-02
| | | | | | | 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.
* Cache: add support for Cache-Control's s-maxage response directive.Piotr Sikora2014-11-18
| | | | Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
* Cache: proxy_cache_lock_age and friends.Roman Arutyunyan2014-11-18
| | | | | | 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.
* Upstream: support named location for X-Accel-Redirect.Toshikuni Fukaya2014-11-04
|
* Upstream: limited next_upstream time and tries when resolving DNS.Gu Feng2014-10-27
| | | | | | 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.
* Upstream: proxy_limit_rate and friends.Roman Arutyunyan2014-10-28
| | | | | | The directives limit the upstream read rate. For example, "proxy_limit_rate 42" limits proxy upstream read rate to 42 bytes per second.
* Cache: hash of Vary headers now stored in cache.Maxim Dounin2014-10-27
| | | | | | | | 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.
* Cache: disable caching of responses with Vary (ticket #118).Maxim Dounin2014-10-27
| | | | | The "proxy_ignore_header" directive now undersands the "Vary" parameter to ignore the header as needed.
* Upstream: proxy_force_ranges and friends.Roman Arutyunyan2014-10-14
| | | | | The directives enable byte ranges for both cached and uncached responses regardless of backend headers.
* Upstream: fix $upstream_cache_last_modified variable.Piotr Sikora2014-10-01
| | | | | | | | | | Due to the u->headers_in.last_modified_time not being correctly initialized, this variable was evaluated to "Thu, 01 Jan 1970 00:00:00 GMT" for responses cached without the "Last-Modified" header which resulted in subsequent proxy requests being sent with "If-Modified-Since: Thu, 01 Jan 1970 00:00:00 GMT" header. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
* Upstream: fixed file buffers reinit in ngx_http_upstream_reinit().Roman Arutyunyan2014-09-18
| | | | | | | Previously, a file buffer start position was reset to the file start. Now it's reset to the previous file buffer end. This fixes reinitialization of requests having multiple successive parts of a single file. Such requests are generated by fastcgi module.
* Upstream: limited next_upstream time and tries (ticket #544).Roman Arutyunyan2014-09-12
| | | | | | | 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.
* Upstream: avoided directly terminating the connection.FengGu2014-08-13
| | | | | | When memory allocation failed in ngx_http_upstream_cache(), the connection would be terminated directly in ngx_http_upstream_init_request(). Return a INTERNAL_SERVER_ERROR response instead.
* Upstream: improved configuration parser diagnostics.Ruslan Ermilov2014-09-01
| | | | | Made it clear when the selected balancing method does not support certain parameters of the "server" directive.
* Upstream: SSL handshake timeouts.Maxim Dounin2014-07-28
| | | | | | | | Timeout may not be set on an upstream connection when we call ngx_ssl_handshake() in ngx_http_upstream_ssl_init_connection(), so make sure to arm it if it's not set. Based on a patch by Yichun Zhang.
* Upstream: ngx_http_upstream_store() error handling fixes.Maxim Dounin2014-07-18
| | | | | | | | | | Previously, ngx_http_map_uri_to_path() errors were not checked in ngx_http_upstream_store(). Moreover, in case of errors temporary files were not deleted, as u->store was set to 0, preventing cleanup code in ngx_http_upstream_finalize_request() from removing them. With this patch, u->store is set to 0 only if there were no errors. Reported by Feng Gu.
* Style: add whitespace between control statement and parentheses.Piotr Sikora2014-07-08
| | | | Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
* Upstream: p->downstream_error instead of closing connection.Maxim Dounin2014-07-04
| | | | | | | | | | Previously, nginx closed client connection in cases when a response body from upstream was needed to be cached or stored but shouldn't be sent to the client. While this is normal for HTTP, it is unacceptable for SPDY. Fix is to use instead the p->downstream_error flag to prevent nginx from sending anything downstream. To make this work, the event pipe code was modified to properly cache empty responses with the flag set.
* Upstream: fixed handling of write event after sending request.Valentin Bartenev2014-07-01
| | | | | | The ngx_http_upstream_dummy_handler() must be set regardless of the read event state. This prevents possible additional call of ngx_http_upstream_send_request_handler().
* Upstream: cache revalidation using If-None-Match.Maxim Dounin2014-06-26
|
* Cache: ETag now saved into cache header.Maxim Dounin2014-06-26
|
* Entity tags: explicit flag to skip not modified filter.Maxim Dounin2014-06-26
| | | | | | | | | | | | | | Previously, last_modified_time was tested against -1 to check if the not modified filter should be skipped. Notably, this prevented nginx from additional If-Modified-Since (et al.) checks on proxied responses. Such behaviour is suboptimal in some cases though, as checks are always skipped on responses from a cache with ETag only (without Last-Modified), resulting in If-None-Match being ignored in such cases. Additionally, it was not possible to return 412 from the If-Unmodified-Since if last modification time was not known for some reason. This change introduces explicit r->disable_not_modified flag instead, which is set by ngx_http_upstream_process_headers().
* Upstream: fixed cache revalidation with SSI.Maxim Dounin2014-06-26
| | | | | | | | Previous code in ngx_http_upstream_send_response() used last modified time from r->headers_out.last_modified_time after the header filter chain was already called. At this point, last_modified_time may be already cleared, e.g., with SSI, resulting in incorrect last modified time stored in a cache file. Fix is to introduce u->headers_in.last_modified_time instead.
* Upstream: removed unused offset to content_length.Maxim Dounin2014-06-26
| | | | | It's not needed since introduction of ngx_http_upstream_content_length() in 103b0d9afe07.
* Upstream: no need to clear r->headers_out.last_modified_time.Maxim Dounin2014-06-26
| | | | | | | | | Clearing of the r->headers_out.last_modified_time field if a response isn't cacheable in ngx_http_upstream_send_response() was introduced in 3b6afa999c2f, the commit to enable not modified filter for cacheable responses. It doesn't make sense though, as at this point header was already sent, and not modified filter was already executed. Therefore, the line was removed to simplify code.
* Upstream: reduced diffs to the plus version of nginx.Ruslan Ermilov2014-06-20
| | | | No functional changes.
* Upstream: generic hash module.Roman Arutyunyan2014-06-02
|
* Upstream: restored workaround for "if".Maxim Dounin2014-04-30
| | | | | | | | The 7022564a9e0e changeset made ineffective workaround from 2464ccebdb52 to avoid NULL pointer dereference with "if". It is now restored by moving the u->ssl_name initialization after the check. Found by Coverity (CID 1210408).
* Upstream: added the "$upstream_cookie_<name>" variables.Vladimir Homutov2014-04-29
|
* Upstream: for ssl name, non-aligned memory allocation is enough.Ruslan Ermilov2014-04-22
|
* Upstream: proxy_ssl_verify and friends.Maxim Dounin2014-04-18
|
* Upstream: proxy_ssl_name and proxy_ssl_server_name directives.Maxim Dounin2014-04-18
| | | | | | | | These directives allow to switch on Server Name Indication (SNI) while connecting to upstream servers. By default, proxy_ssl_server_name is currently off (that is, no SNI) and proxy_ssl_name is set to a host used in the proxy_pass directive.
* Range filter: single_range flag in request.Maxim Dounin2014-03-21
| | | | | | | | | | | | If set, it means that response body is going to be in more than one buffer, hence only range requests with a single range should be honored. The flag is now used by mp4 and cacheable upstream responses, thus allowing range requests of mp4 files with start/end, as well as range processing on a first request to a not-yet-cached files with proxy_cache. Notably this makes it possible to play mp4 files (with proxy_cache, or with mp4 module) on iOS devices, as byte-range support is required by Apple.
* Upstream: fixed error message wording.Konstantin Pavlov2014-02-20
|
* Upstream: ngx_post_event() instead of upgraded call (ticket #503).Maxim Dounin2014-02-18
| | | | | | | | | | | | If a request is finalized in the first call to the ngx_http_upstream_process_upgraded() function, e.g., because upstream server closed the connection for some reason, in the second call the u->peer.connection pointer will be null, resulting in segmentation fault. Fix is to avoid second direct call, and post event instead. This ensures that ngx_http_upstream_process_upgraded() won't be called again if a request is finalized.
* Use ngx_socket_errno where appropriate.Piotr Sikora2014-02-03
| | | | Signed-off-by: Piotr Sikora <piotr@cloudflare.com>