summaryrefslogtreecommitdiffhomepage
path: root/src (follow)
AgeCommit message (Collapse)AuthorFilesLines
2018-03-17The gRPC proxy module.Maxim Dounin1-0/+4571
The module allows passing requests to upstream gRPC servers. The module is built by default as long as HTTP/2 support is compiled in. Example configuration: grpc_pass 127.0.0.1:9000; Alternatively, the "grpc://" scheme can be used: grpc_pass grpc://127.0.0.1:9000; Keepalive support is available via the upstream keepalive module. Note that keepalive connections won't currently work with grpc-go as it fails to handle SETTINGS_HEADER_TABLE_SIZE. To use with SSL: grpc_pass grpcs://127.0.0.1:9000; SSL connections use ALPN "h2" when available. At least grpc-go works fine without ALPN, so if ALPN is not available we just establish a connection without it. Tested with grpc-c++ and grpc-go.
2018-03-17Upstream: u->conf->preserve_output flag.Maxim Dounin2-2/+5
The flag can be used to continue sending request body even after we've got a response from the backend. In particular, this is needed for gRPC proxying of bidirectional streaming RPCs, and also to send control frames in other forms of RPCs.
2018-03-17Upstream: u->request_body_blocked flag.Maxim Dounin2-2/+20
The flag indicates whether last ngx_output_chain() returned NGX_AGAIN or not. If the flag is set, we arm the u->conf->send_timeout timer. The flag complements c->write->ready test, and allows to stop sending the request body in an output filter due to protocol-specific flow control.
2018-03-17Upstream: trailers support, u->conf->pass_trailers flag.Maxim Dounin2-0/+98
Basic trailer headers support allows one to access response trailers via the $upstream_trailer_* variables. Additionally, the u->conf->pass_trailers flag was introduced. When the flag is set, trailer headers from the upstream response are passed to the client. Like normal headers, trailer headers will be hidden if present in u->conf->hide_headers_hash.
2018-03-17HTTP/2: externalized various constants and interfaces.Maxim Dounin5-91/+129
2018-03-12Style.Roman Arutyunyan1-3/+3
2018-03-12Stream ssl_preread: $ssl_preread_alpn_protocols variable.Roman Arutyunyan1-6/+122
The variable keeps a comma-separated list of protocol names from ALPN TLS extension defined by RFC 7301.
2018-03-07Improved code readablity.Ruslan Ermilov2-4/+12
No functional changes.
2018-03-05HTTP/2: unknown frames now logged at info level.Maxim Dounin1-2/+2
2018-03-05Style.Maxim Dounin1-1/+2
2018-03-01Access log: support for disabling escaping (ticket #1450).Vladimir Homutov2-16/+120
Based on patches by Johannes Baiter <johannes.baiter@bsb-muenchen.de> and Calin Don.
2018-03-01Core: ngx_current_msec now uses monotonic time if available.Maxim Dounin1-1/+29
When clock_gettime(CLOCK_MONOTONIC) (or faster variants, _FAST on FreeBSD, and _COARSE on Linux) is available, we now use it for ngx_current_msec. This should improve handling of timers if system time changes (ticket #189).
2018-03-01Postpone filter: prevented uninitialized r->out.Roman Arutyunyan1-5/+5
The r->out chain link could be left uninitialized in case of error. A segfault could happen if the subrequest handler accessed it. The issue was introduced in commit 20f139e9ffa8.
2018-02-28Generic subrequests in memory.Roman Arutyunyan7-188/+107
Previously, only the upstream response body could be accessed with the NGX_HTTP_SUBREQUEST_IN_MEMORY feature. Now any response body from a subrequest can be saved in a memory buffer. It is available as a single buffer in r->out and the buffer size is configured by the subrequest_output_buffer_size directive. Upstream, proxy and fastcgi code used to handle the old-style feature is removed.
2018-02-22Modules compatibility: additional upstream metrics.Vladimir Homutov1-0/+1
2018-02-26Auth basic: prevent null character in error log (ticket #1494).Vadim Filimonov1-2/+2
2018-02-22Generate error for unsupported IPv6 transparent proxy.Roman Arutyunyan1-0/+9
On some platforms (for example, Linux with glibc 2.12-2.25) IPv4 transparent proxying is available, but IPv6 transparent proxying is not. The entire feature is enabled in this case and NGX_HAVE_TRANSPARENT_PROXY macro is set to 1. Previously, an attempt to enable transparency for an IPv6 socket was silently ignored in this case and was usually followed by a bind(2) EADDRNOTAVAIL error (ticket #1487). Now the error is generated for unavailable IPv6 transparent proxy.
2018-02-22HTTP/2: style.Ruslan Ermilov1-17/+4
Unified the style of validity checks in ngx_http_v2_validate_header().
2018-02-21Geo: fixed indentation.Sergey Kandaurov1-11/+11
2018-02-21Geo: optimized configuration parser.Ruslan Ermilov2-2/+10
If the geo block parser has failed, doing more things is pointless.
2018-02-21Geo: fixed memory allocation error handling (closes #1482).Ruslan Ermilov2-22/+32
If during configuration parsing of the geo directive the memory allocation has failed, pool used to parse configuration inside the block, and sometimes the temporary pool were not destroyed.
2018-02-21Version bump.Ruslan Ermilov1-2/+2
2018-02-15HTTP/2: precalculate hash for "Cookie".Maxim Dounin1-1/+2
There is no need to calculate hashes of static strings at runtime. The ngx_hash() macro can be used to do it during compilation instead, similarly to how it is done in ngx_http_proxy_module.c for "Server" and "Date" headers.
2018-02-15HTTP/2: fixed ngx_http_v2_push_stream() allocation error handling.Ruslan Ermilov1-15/+47
In particular, if a stream object allocation failed, and a client sent the PRIORITY frame for this stream, ngx_http_v2_set_dependency() could dereference a null pointer while trying to re-parent a dependency node.
2018-02-15HTTP/2: push additional request headers (closes #1478).Ruslan Ermilov3-94/+214
The Accept-Encoding, Accept-Language, and User-Agent header fields are now copied from the original request to pushed requests.
2018-02-15Expose more headers with NGX_HTTP_HEADERS.Ruslan Ermilov2-2/+2
2018-02-15Core: added a stub for additional zone configuration.Vladimir Homutov1-0/+1
2018-02-15HTTP/2: style.Sergey Kandaurov2-4/+4
2018-02-09HTTP/2: fixed null pointer dereference with server push.Ruslan Ermilov1-1/+5
r->headers_in.host can be NULL in ngx_http_v2_push_resource(). This happens when a request is terminated with 400 before the :authority or Host header is parsed, and either pushing is enabled on the server{} level or error_page 400 redirects to a location with pushes configured. Found by Coverity (CID 1429156).
2018-02-08HTTP/2: fixed build with -Werror=unused-but-set-variable.Ruslan Ermilov1-10/+3
2018-02-08HTTP/2: server push.Ruslan Ermilov5-18/+873
Resources to be pushed are configured with the "http2_push" directive. Also, preload links from the Link response headers, as described in https://www.w3.org/TR/preload/#server-push-http-2, can be pushed, if enabled with the "http2_push_preload" directive. Only relative URIs with absolute paths can be pushed. The number of concurrent pushes is normally limited by a client, but cannot exceed a hard limit set by the "http2_max_concurrent_pushes" directive.
2018-02-08HTTP/2: changed prototypes of request pseudo-headers parsers.Ruslan Ermilov1-25/+24
No functional changes.
2018-02-08Basic support of the Link response header.Ruslan Ermilov4-19/+32
2018-02-07Dav: added error logging.Roman Arutyunyan1-1/+10
Previously, when request body was not available or was previously read in memory rather than a file, client received HTTP 500 error, but no explanation was logged in error log. This could happen, for example, if request body was read or discarded prior to error_page redirect, or if mirroring was enabled along with dav.
2018-02-06HTTP/2: removed unused field from ngx_http_v2_stream_t.Sergey Kandaurov1-2/+0
2018-01-30Upstream: removed X-Powered-By from the list of special headers.Ruslan Ermilov1-4/+0
After 1e720b0be7ec, it's neither specially processed nor copied when redirecting with X-Accel-Redirect.
2018-01-30SSL: using default server context in session remove (closes #1464).Sergey Kandaurov3-6/+6
This fixes segfault in configurations with multiple virtual servers sharing the same port, where a non-default virtual server block misses certificate.
2018-01-30HTTP/2: finalize request as bad if parsing of pseudo-headers fails.Ruslan Ermilov1-8/+1
This is in line when the required pseudo-headers are missing, and avoids spurious zero statuses in access.log.
2018-01-29HTTP/2: more style, comments, and debugging.Ruslan Ermilov3-158/+168
2018-01-29HTTP/2: handle duplicate INITIAL_WINDOW_SIZE settings.Ruslan Ermilov1-2/+2
2018-01-16Fixed --test-build-eventport on macOS 10.12 and later.Ruslan Ermilov1-0/+2
In macOS 10.12, CLOCK_REALTIME and clockid_t were added, but not timer_t.
2018-01-11Upstream: fixed "header already sent" alerts on backend errors.Maxim Dounin1-3/+4
Following ad3f342f14ba046c (1.9.13), it is possible that a request where header was already sent will be finalized with NGX_HTTP_BAD_GATEWAY, triggering an attempt to return additional error response and the "header already sent" alert as a result. In particular, it is trivial to reproduce the problem with a HEAD request and caching enabled. With caching enabled nginx will change HEAD to GET and will set u->pipe->downstream_error to suppress sending the response body to the client. When a backend-related error occurs (for example, proxy_read_timeout expires), ngx_http_finalize_upstream_request() will be called with NGX_HTTP_BAD_GATEWAY. After ad3f342f14ba046c this will result in ngx_http_finalize_request(NGX_HTTP_BAD_GATEWAY). Fix is to move u->pipe->downstream_error handling to a later point, where all special response codes are changed to NGX_ERROR. Reported by Jan Prachar, http://mailman.nginx.org/pipermail/nginx-devel/2018-January/010737.html.
2017-12-30Version bump.Maxim Dounin1-2/+2
2017-12-21Allowed configuration token to start with a variable.Roman Arutyunyan1-0/+5
Specifically, it is now allowed to start with a variable expression with braces: ${name}. The opening curly bracket in such a token was previously considered the start of a new block. Variables located anywhere else in a token worked fine: foo${name}.
2017-12-19Fixed capabilities version.Roman Arutyunyan1-1/+1
Previously, capset(2) was called with the 64-bit capabilities version _LINUX_CAPABILITY_VERSION_3. With this version Linux kernel expected two copies of struct __user_cap_data_struct, while only one was submitted. As a result, random stack memory was accessed and random capabilities were requested by the worker. This sometimes caused capset() errors. Now the 32-bit version _LINUX_CAPABILITY_VERSION_1 is used instead. This is OK since CAP_NET_RAW is a 32-bit capability (CAP_NET_RAW = 13).
2017-12-18Improved the capabilities feature detection.Roman Arutyunyan2-2/+2
Previously included file sys/capability.h mentioned in capset(2) man page, belongs to the libcap-dev package, which may not be installed on some Linux systems when compiling nginx. This prevented the capabilities feature from being detected and compiled on that systems. Now linux/capability.h system header is included instead. Since capset() declaration is located in sys/capability.h, now capset() syscall is defined explicitly in code using the SYS_capset constant, similarly to other Linux-specific features in nginx.
2017-12-13Retain CAP_NET_RAW capability for transparent proxying.Roman Arutyunyan5-0/+51
The capability is retained automatically in unprivileged worker processes after changing UID if transparent proxying is enabled at least once in nginx configuration. The feature is only available in Linux.
2017-12-11Use sysconf to determine cacheline size at runtime.Debayan Ghosh1-0/+10
Determine cacheline size at runtime if supported using sysconf(_SC_LEVEL1_DCACHE_LINESIZE). In case not supported, fallback to compile time defaults.
2017-11-20Proxy: escape explicit space in URI in default cache key.Roman Arutyunyan1-1/+1
If the flag space_in_uri is set, the URI in HTTP upstream request is escaped to convert space to %20. However this flag is not checked while creating the default cache key. This leads to different cache keys for requests '/foo bar' and '/foo%20bar', while the upstream requests are identical. Additionally, the change fixes background cache updates when the client URI contains unescaped space. Default cache key in a subrequest is always based on escaped URI, while the main request may not escape it. As a result, background cache update subrequest may update a different cache entry.
2017-11-20Inherit valid_unparsed_uri in cloned subrequests (ticket #1430).Roman Arutyunyan1-0/+1
Inheriting this flag will make the cloned subrequest behave consistently with the parent. Specifically, the upstream HTTP request and cache key created by the proxy module may depend directly on unparsed_uri if valid_unparsed_uri flag is set. Previously, the flag was zero for cloned requests, which could make background update proxy a request different than its parent and cache the result with a different key. For example, if client URI contained the escaped slash character %2F, it was used as is by the proxy module in the main request, but was unescaped in the subrequests. Similar problems exist in the slice module.