summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules (follow)
AgeCommit message (Collapse)AuthorFilesLines
2017-04-20Gzip static: use an appropriate error on memory allocation failure.Sergey Kandaurov1-1/+1
2017-04-20Cleaned up r->headers_out.headers allocation error handling.Sergey Kandaurov6-10/+21
If initialization of a header failed for some reason after ngx_list_push(), leaving the header as is can result in uninitialized memory access by the header filter or the log module. The fix is to clear partially initialized headers in case of errors. For the Cache-Control header, the fix is to postpone pushing r->headers_out.cache_control until its value is completed.
2017-04-18Sub filter: restored ngx_http_set_ctx() at the proper place.Sergey Kandaurov1-2/+2
Previously, ngx_http_sub_header_filter() could fail with a partially initialized context, later accessed in ngx_http_sub_body_filter() if called from the perl content handler. The issue had appeared in 2c045e5b8291 (1.9.4). A better fix would be to handle ngx_http_send_header() errors in the perl module, though this doesn't seem to be easy enough.
2017-04-18SSL: added support for TLSv1.3 in ssl_protocols directive.Sergey Kandaurov3-0/+3
Support for the TLSv1.3 protocol will be introduced in OpenSSL 1.1.1.
2017-04-11Added support for the "308 Permanent Redirect" (ticket #877).Simon Leblanc2-0/+3
2017-04-12Use ngx_calloc_buf() where appropriate.Ruslan Ermilov7-10/+10
2017-03-24Upstream: allow recovery from "429 Too Many Requests" response.Piotr Sikora4-0/+4
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-03-31Slice filter: prevented slice redirection (ticket #1219).Roman Arutyunyan1-1/+11
When a slice subrequest was redirected to a new location, its context was lost. After its completion, a new slice subrequest for the same slice was created. This could lead to infinite loop. Now the slice module makes sure each slice subrequest starts output with the slice context available.
2017-03-28Slice filter: allowed at most one subrequest at a time.Roman Arutyunyan1-12/+16
Previously, if slice main request write handler was called while a slice subrequest was running, a new subrequest for the same slice was started.
2017-04-02Moved handling of wev->delayed to the connection event handler.Maxim Dounin2-8/+2
With post_action or subrequests, it is possible that the timer set for wev->delayed will expire while the active subrequest write event handler is not ready to handle this. This results in request hangs as observed with limit_rate / sendfile_max_chunk and post_action (ticket #776) or subrequests (ticket #1228). Moving the handling to the connection event handler fixes the hangs observed, and also slightly simplifies the code.
2017-04-02Perl: fixed delaying subrequests.Maxim Dounin2-6/+11
Much like in limit_req, use the wev->delayed flag to ensure proper handling and interoperability with limit_rate.
2017-04-02Limit req: fixed delaying subrequests.Maxim Dounin1-1/+4
Since limit_req uses connection's write event to delay request processing, it can conflict with timers in other subrequests. In particular, even if applied to an active subrequest, it can break things if wev->delayed is already set (due to limit_rate or sendfile_max_chunk), since after limit_req finishes the wev->delayed flag will be set and no timer will be active. Fix is to use the wev->delayed flag in limit_req as well. This ensures that wev->delayed won't be set after limit_req finishes, and also ensures that limit_req's timers will be properly handled by other subrequests if the one delayed by limit_req is not active.
2017-03-28Fixed ngx_open_cached_file() error handling.Sergey Kandaurov2-3/+8
If of.err is 0, it means that there was a memory allocation error and no further logging and/or processing is needed. The of.failed string can be only accessed if of.err is not 0.
2017-03-07Access log: removed dead ev->timedout check in flush timer handler.Maxim Dounin1-14/+1
The ev->timedout flag is set on first timer expiration, and never reset after it. Due to this the code to stop the timer when the timer was canceled never worked (except in a very specific time frame immediately after start), and the timer was always armed again. This essentially resulted in a buffer flush at the end of an event loop iteration. This behaviour actually seems to be better than just stopping the flush timer for the whole shutdown, so it is preserved as is instead of fixing the code to actually remove the timer. It will be further improved by upcoming changes to preserve cancelable timers if there are other timers blocking shutdown.
2017-03-02Added missing static specifiers.Eran Kornblau4-4/+4
2017-02-13Gzip: free chain links on the hot path (ticket #1046).Maxim Dounin1-6/+16
2017-02-10Slice filter: fetch slices in cloned subrequests.Roman Arutyunyan1-1/+4
Previously, slice subrequest location was selected based on request URI. If request is then redirected to a new location, its context array is cleared, making the slice module loose current slice range information. This lead to broken output. Now subrequests with the NGX_HTTP_SUBREQUEST_CLONE flag are created for slices. Such subrequests stay in the same location as the parent request and keep the right slice context.
2017-02-10Upstream: proxy_cache_background_update and friends.Roman Arutyunyan4-0/+44
The directives enable cache updates in subrequests.
2017-01-31Variables: generic prefix variables.Dmitry Volyntsev1-10/+3
2016-12-24Win32: fixed some warnings reported by Borland C.Maxim Dounin1-2/+2
Most notably, warning W8012 (comparing signed and unsigned values) reported in multiple places where an unsigned value of small type (e.g., u_short) is promoted to an int and compared to an unsigned value. Warning W8072 (suspicious pointer arithmetic) disabled, it is reported when we increment base pointer in ngx_shm_alloc().
2016-12-22Fixed missing "Location" field with some relative redirects.Ruslan Ermilov2-12/+6
Relative redirects did not work with directory redirects and auto redirects issued by nginx.
2016-12-15Access log: support for json escaping.Valentin Bartenev1-6/+77
2016-12-08Map: the "volatile" parameter.Ruslan Ermilov1-1/+14
By default, "map" creates cacheable variables [1]. With this parameter it creates a non-cacheable variable. An original idea was to deduce the cacheability of the "map" variable by checking the cacheability of variables specified in source and resulting values, but it turned to be too hard. For example, a cacheable variable can be overridden with the "set" directive or with the SSI "set" command. Also, keeping "map" variables cacheable by default is good for performance reasons. This required adding a new parameter. [1] Before db699978a33f (1.11.0), the cacheability of the "map" variable could vary depending on the cacheability of variables specified in resulting values (ticket #1090). This is believed to be a bug rather than a feature.
2016-12-08Map: simplified "map" block parser.Ruslan Ermilov1-1/+2
No functional changes.
2016-12-07Perl: added PERL_SET_INTERP().Maxim Dounin1-0/+8
For Perl compiled with threads, without PERL_SET_INTERP() the PL_curinterp remains set to the first interpreter created (that is, one created at original start). As a result after a reload Perl thinks that operations are done withing a thread, and, most notably, denies to change environment. For example, the following code properly works on original start, but fails after a reload: perl 'sub { my $r = shift; $r->send_http_header("text/plain"); $ENV{TZ} = "UTC"; $r->print("tz: " . $ENV{TZ} . " (localtime " . (localtime()) . ")\n"); $ENV{TZ} = "Europe/Moscow"; $r->print("tz: " . $ENV{TZ} . " (localtime " . (localtime()) . ")\n"); return OK; }'; To fix this, PERL_SET_INTERP() added anywhere where PERL_SET_CONTEXT() was previously used. Note that PERL_SET_INTERP() doesn't seem to be documented anywhere. Yet it is used in some other software, and also seems to be the only solution possible.
2016-11-22Mp4: fixed setting wrong mdat atom size in very rare cases.hucongcong1-1/+3
Atom size is the sum of atom header size and atom data size. The specification says that the first 4 bytes are set to one when the atom size is greater than the maximum unsigned 32-bit value. Which means atom header size should be considered when the comparison takes place between atom data size and 0xffffffff.
2016-12-05SSL: $ssl_curves (ticket #1088).Maxim Dounin1-0/+3
The variable contains a list of curves as supported by the client. Known curves are listed by their names, unknown ones are shown in hex, e.g., "0x001d:prime256v1:secp521r1:secp384r1". Note that OpenSSL uses session data for SSL_get1_curves(), and it doesn't store full list of curves supported by the client when serializing a session. As a result $ssl_curves is only available for new sessions (and will be empty for reused ones). The variable is only meaningful when using OpenSSL 1.0.2 and above. With older versions the variable is empty.
2016-12-05SSL: $ssl_ciphers (ticket #870).Maxim Dounin1-0/+3
The variable contains list of ciphers as supported by the client. Known ciphers are listed by their names, unknown ones are shown in hex, e.g., ""AES128-SHA:AES256-SHA:0x00ff". The variable is fully supported only when using OpenSSL 1.0.2 and above. With older version there is an attempt to provide some information using SSL_get_shared_ciphers(). It only lists known ciphers though. Moreover, as OpenSSL uses session data for SSL_get_shared_ciphers(), and it doesn't store relevant data when serializing a session. As a result $ssl_ciphers is only available for new sessions (and not available for reused ones) when using OpenSSL older than 1.0.2.
2016-12-05SSL: $ssl_client_v_start, $ssl_client_v_end, $ssl_client_v_remain.Maxim Dounin1-0/+9
2016-11-10Range filter: only initialize ctx->ranges in main request.hucongcong1-6/+6
It is not necessary to initialize ctx->ranges in all request, because ctx->ranges in subrequest will be reassigned to ctx->ranges of main request.
2016-11-02Cache: proxy_cache_max_range_offset and friends.Dmitry Volyntsev4-0/+48
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-11-01Perl: fixed optimization in SSI command handler.Maxim Dounin1-1/+1
As the pointer to the first argument was tested instead of the argument itself, array of arguments was always created, even if there were no arguments. Fix is to test args[0] instead of args. Found by Coverity (CID 1356862).
2016-10-31Upstream: added the ngx_http_upstream_resolved_t.name field.Ruslan Ermilov4-16/+8
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-31Upstream: removed unnecessary condition in proxy_eval() and friends.Ruslan Ermilov4-4/+4
The first condition added in d3454e719bbb should have just replaced the second one.
2016-10-27Mp4: introduced custom version of ngx_atofp().Maxim Dounin1-14/+60
This allows to correctly parse "start" and "end" arguments without null-termination (ticket #475), and also fixes rounding errors observed with strtod() when using i387 instructions.
2016-10-16Proxy: support variables for proxy_method directive.Dmitry Lazurkin1-6/+10
2016-10-21SSL: RFC2253 compliant $ssl_client_s_dn and $ssl_client_i_dn.Dmitry Volyntsev1-0/+6
Originally, the variables kept a result of X509_NAME_oneline(), which is, according to the official documentation, a legacy function. It produces a non standard output form and has various quirks and inconsistencies. The RFC2253 compliant behavior is introduced for these variables. The original variables are available through $ssl_client_s_dn_legacy and $ssl_client_i_dn_legacy.
2016-10-21Image filter: support for WebP.Valentin Bartenev1-5/+159
In collaboration with Ivan Poluyanov.
2016-10-14Upstream: handling of proxy_set_header at http level.Maxim Dounin4-0/+56
When headers are set at the "http" level and not redefined in a server block, we now preserve conf->headers into the "http" section configuration to inherit it to all servers. The same applies to conf->headers_cache, though it may not be effective if no servers use cache at the "server" level as conf->headers_cache is only initialized if cache is enabled on a given level. Similar changes made in fastcgi/scgi/uwsgi to preserve conf->params and conf->params_cache.
2016-10-14Proxy: do not create conf->headers_source when not needed.Maxim Dounin1-15/+10
2016-10-06Realip: fixed duplicate processing on redirects (ticket #1098).Maxim Dounin1-4/+4
Duplicate processing was possible if the address set by realip was listed in set_realip_from, and there was an internal redirect so module context was cleared. This resulted in exactly the same address being set, so this wasn't a problem before the $realip_remote_addr variable was introduced, though now results in incorrect $realip_remote_addr being picked. Fix is to use ngx_http_realip_get_module_ctx() to look up module context even if it was cleared. Additionally, the order of checks was switched to check the configuration first as it looks more effective.
2016-10-03Addition filter: set last_in_chain flag when clearing last_buf.Roman Arutyunyan1-0/+1
When the last_buf flag is cleared for add_after_body to append more data from a subrequest, other filters may still have buffered data, which should be flushed at this point. For example, the sub_filter may have a partial match buffered, which will only be flushed after the subrequest is done, ending up with interleaved data in output. Setting last_in_chain instead of last_buf flushes the data and fixes the order of output buffers.
2016-10-03Do not set last_buf flag in subrequests.Roman Arutyunyan2-2/+3
The last_buf flag should only be set in the last buffer of the main request. Otherwise, several last_buf flags can appear in output. This can, for example, break the chunked filter, which will include several final chunks in output.
2016-09-22Upstream: max_conns.Ruslan Ermilov3-0/+23
2016-09-22Upstream: removed the quick recovery mechanism.Ruslan Ermilov1-6/+0
Its usefulness it questionable, and it interacts badly with max_conns.
2016-09-22Upstream: style.Maxim Dounin2-2/+0
2016-09-20Perl: pass additional linker options to perl module.Konstantin Pavlov1-0/+2
Previously flags passed by --with-ld-opt were not used when building perl module, which meant hardening flags provided by package build systems were not applied.
2016-09-16Upstream hash: fixed missing upstream name initialization.Vladimir Homutov1-0/+1
2016-09-01Realip: fixed uninitialized memory access.Roman Arutyunyan1-1/+1
Previously, the realip module could be left with uninitialized context after an error in the ngx_http_realip_set_addr() function. That context could be later accessed by $realip_remote_addr and $realip_remote_port variable handlers.
2016-08-25Geo: fixed indentation.Sergey Kandaurov1-5/+5