summaryrefslogtreecommitdiffhomepage
path: root/src/http/ngx_http_upstream.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2011-12-26Cache locks initial implementation.Maxim Dounin1-0/+3
New directives: proxy_cache_lock on/off, proxy_cache_lock_timeout. With proxy_cache_lock set to on, only one request will be allowed to go to upstream for a particular cache item. Others will wait for a response to appear in cache (or cache lock released) up to proxy_cache_lock_timeout. Waiting requests will recheck if they have cached response ready (or are allowed to run) every 500ms. Note: we intentionally don't intercept NGX_DECLINED possibly returned by ngx_http_file_cache_read(). This needs more work (possibly safe, but needs further investigation). Anyway, it's exceptional situation. Note: probably there should be a way to disable caching of responses if there is already one request fetching resource to cache (without waiting at all). Two possible ways include another cache lock option ("no_cache") or using proxy_no_cache with some supplied variable. Note: probably there should be a way to lock updating requests as well. For now "proxy_cache_use_stale updating" is available.
2011-12-19Added clearing of r->valid_unparsed_uri on internal redirects.Maxim Dounin1-2/+0
This resolves issue with try_files (see ticket #70), configuration like location / { try_files $uri /index.php; } location /index.php { proxy_pass http://backend; } caused nginx to use original request uri in a request to a backend. Historically, not clearing of the r->valid_unparsed_uri on internal redirect was a feature: it allowed to pass the same request to (another) upstream server via error_page redirection. Since then named locations appeared though, and it's time to start resetting r->valid_unparsed_uri on internal redirects. Configurations still using this feature should be converted to use named locations instead. Patch by Lanshun Zhou.
2011-12-09Added the ngx_http_upstream_param_set_slot().Valentin Bartenev1-0/+44
2011-11-18Upstream: don't cache unfinished responses.Maxim Dounin1-2/+10
Check if received data length match Content-Length header (if present), don't cache response if no match found. This prevents caching of corrupted response in case of premature connection close by upstream.
2011-10-11Additional headers for proxy/fastcgi/uwsgi/scgi_ignore_headers.Maxim Dounin1-6/+26
Now the following headers may be ignored as well: X-Accel-Limit-Rate, X-Accel-Buffering, X-Accel-Charset.
2011-10-07Tweaked error messages.Ruslan Ermilov1-5/+5
2011-10-05Fixed cache bypass caching of non-cacheable replies (ticket #21).Maxim Dounin1-4/+2
If cache was bypassed with proxy_cache_bypass, cache-controlling headers (Cache-Control, Expires) wasn't considered and response was cached even if it was actually non-cacheable. Patch by John Ferlito.
2011-09-27Better handling of late upstream creation.Maxim Dounin1-0/+4
Configuration with duplicate upstream blocks defined after first use, i.e. like server { ... location / { proxy_pass http://backend; } } upstream backend { ... } upstream backend { ... } now correctly results in "duplicate upstream" error. Additionally, upstream blocks defined after first use now handle various server directive parameters ("weight", "max_fails", etc.). Previously configuration like server { ... location / { proxy_pass http://backend; } } upstream backend { server 127.0.0.1 max_fails=5; } incorrectly resulted in "invalid parameter "max_fails=5"" error.
2011-09-27Cache: fix for sending of stale responses.Maxim Dounin1-1/+6
For normal cached responses ngx_http_cache_send() sends last buffer and then request finalized via ngx_http_finalize_request() call, i.e. everything is ok. But for stale responses (i.e. when upstream died, but we have something in cache) the same ngx_http_cache_send() sends last buffer, but then in ngx_http_upstream_finalize_request() another last buffer is send. This causes duplicate final chunk to appear if chunked encoding is used (and resulting problems with keepalive connections and so on). Fix this by not sending in ngx_http_upstream_finalize_request() another last buffer if we know response was from cache.
2011-09-25Upstream: clearing of u->peer.connection on close.Maxim Dounin1-0/+1
This fixes crashes observed with some 3rd party balancer modules. Standard balancer modules (round-robin and ip hash) explicitly set pc->connection (aka u->peer.connection) to NULL and aren't affected.
2011-09-20Fix of separate pool for upstream connections (r4117).Maxim Dounin1-2/+8
Pool may not be created if connection was created but rejected in connect() call. Make sure to check if it is here before trying to destroy it.
2011-09-15Upstream: Connection header processing.Maxim Dounin1-1/+20
2011-09-15Upstream: Transfer-Encoding header processing.Maxim Dounin1-0/+24
2011-09-15Upstream: keepalive flag.Maxim Dounin1-1/+8
This patch introduces r->upstream->keepalive flag, which is set by protocol handlers if connection to upstream is in good state and can be kept alive.
2011-09-15Upstream: pipe length and input_filter_init in buffered mode.Maxim Dounin1-0/+9
As long as ngx_event_pipe() has more data read from upstream than specified in p->length it's passed to input filter even if buffer isn't yet full. This allows to process data with known length without relying on connection close to signal data end. By default p->length is set to -1 in upstream module, i.e. end of data is indicated by connection close. To set it from per-protocol handlers upstream input_filter_init() now called in buffered mode (as well as in unbuffered mode).
2011-09-15Upstream: r->upstream->length type change to off_t.Maxim Dounin1-11/+2
Previous use of size_t may cause wierd effects on 32bit platforms with certain big responses transferred in unbuffered mode. Nuke "if (size > u->length)" check as it's not usefull anyway (preread body data isn't subject to this check) and now requires additional check for u->length being positive.
2011-09-15Upstream: content_length_n API change.Maxim Dounin1-27/+26
We no longer use r->headers_out.content_length_n as a primary source of backend's response length. Instead we parse response length to u->headers_in.content_length_n and copy to r->headers_out.content_length_n when needed.
2011-09-15Upstream: separate pool for peer connections.Maxim Dounin1-1/+15
This is required to support persistent https connections as various ssl structures are allocated from connection's pool.
2011-09-15Workaround for cpu hog on errors with cached connections.Maxim Dounin1-0/+4
Just doing another connect isn't safe as peer.get() may expect peer.tries to be strictly positive (this is the case e.g. with round robin with multiple upstream servers). Increment peer.tries to at least avoid cpu hog in round robin balancer (with the patch alert will be seen instead). This is not enough to fully address the problem though, hence TODO. We should be able to inform balancer that the error wasn't considered fatal and it may make sense to retry the same peer.
2011-09-15API change: ngx_chain_update_chains() now requires pool.Maxim Dounin1-1/+1
The ngx_chain_update_chains() needs pool to free chain links used for buffers with non-matching tags. Providing one helps to reduce memory consumption for long-lived requests.
2011-07-29update r3945 with more descriptive error messageIgor Sysoev1-3/+5
2011-07-22finalizing with rc == 0 in unbuffered proxy mode caused nginx to waitIgor Sysoev1-1/+2
for another send_timeout before actually closing client's connection if client timed out while still talking to upstream server patch by Maxim Dounin
2011-07-19fix segfault if cache key is larger than upstream buffer sizeIgor Sysoev1-0/+9
patch by Lanshun Zhou
2011-06-28revert r3935 and fix "stalled cache updating" alertIgor Sysoev1-16/+10
by freeing cache at upstream finalize phase patch by Maxim Dounin
2011-06-01fix "stalled cache updating" alert,Igor Sysoev1-0/+9
when non-cachable HEAD response did not not free an expired cache node
2011-05-13fix a broken cached response if bypass/no_cache directive values are different,Igor Sysoev1-25/+13
the bug has been introduced in r3700
2011-04-21allow to use $upstream_... variables in SSIIgor Sysoev1-5/+5
2011-04-04fix case when a host in fastcgi_pass, scgi_pass, and uwsgi_passIgor Sysoev1-0/+8
is given by expression and refers to a defined upstream
2010-07-28move debug logging inside ngx_http_file_cache_free()Igor Sysoev1-6/+0
2010-07-28several changes in cache cleanup handling:Igor Sysoev1-4/+4
*) now ngx_http_file_cache_cleanup() uses ngx_http_file_cache_free() *) ngx_http_file_cache_free() interface has been changed to accept r->cache ngx_http_file_cache_cleanup() must use r->cache, but not r, because there can be several r->cache's during request processing, r->cache may be NULL at request finalising, etc. *) test if updating request does not complete correctly
2010-07-27fix r3707: cache node should be freed be a response is not cachedIgor Sysoev1-1/+1
2010-07-27fix typoIgor Sysoev1-1/+1
2010-07-19an intercepted error code was not cachedIgor Sysoev1-0/+18
2010-07-19style fixIgor Sysoev1-2/+1
2010-07-19proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypassIgor Sysoev1-3/+52
2010-07-16rename ngx_http_file_cache_create() to ngx_http_file_cache_new()Igor Sysoev1-1/+1
2010-07-15ngx_http_file_cache_create()Igor Sysoev1-9/+3
2010-07-14use ngx_http_test_predicates(), ngx_http_set_predicate_slot()Igor Sysoev1-5/+3
delete ngx_http_cache(), ngx_http_no_cache_set_slot()
2010-07-02treat Set-Cookie as a header that forbids cachingIgor Sysoev1-1/+22
2010-07-02use shared ngx_http_upstream_ignore_headers_masks[]Igor Sysoev1-0/+9
2010-05-24remove r->zero_in_uriIgor Sysoev1-4/+0
2010-05-24proxy_no_cache and fastcgi_no_cacheIgor Sysoev1-0/+7
2010-05-14do not cache response if it has "no-store" or "private"Igor Sysoev1-4/+6
in "Cache-Control" header
2010-05-14ngx_str_set() and ngx_str_null()Igor Sysoev1-2/+1
2010-05-14use ngx_min() and ngx_max()Igor Sysoev1-1/+1
2010-05-14fix segfault: ngx_http_upstream_cleanup() cleans r->cleanup,Igor Sysoev1-2/+0
the bug had been introduced in r3419
2010-01-29delete u->cleanup mark, this fixes large values in $upstream_response_time,Igor Sysoev1-0/+2
the bug had been introduced in r3007
2009-12-23allow to handle 301/302 in error_pageIgor Sysoev1-1/+1
2009-12-23fix typoIgor Sysoev1-1/+1
2009-11-29fix handling cached HTTP/0.9 responseIgor Sysoev1-0/+5