summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules/ngx_http_proxy_module.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-07-06Proxy: style.Maxim Dounin1-2/+2
2020-07-06Proxy: detection of data after final chunk.Maxim Dounin1-1/+30
Previously, additional data after final chunk was either ignored (in the same buffer, or during unbuffered proxying) or sent to the client (in the next buffer already if it was already read from the socket). Now additional data are properly detected and ignored in all cases. Additionally, a warning is now logged and keepalive is disabled in the connection.
2020-07-06Proxy: drop extra data sent by upstream.Maxim Dounin1-9/+43
Previous behaviour was to pass everything to the client, but this seems to be suboptimal and causes issues (ticket #1695). Fix is to drop extra data instead, as it naturally happens in most clients.
2019-03-03SSL: fixed potential leak on memory allocation errors.Maxim Dounin1-0/+1
If ngx_pool_cleanup_add() fails, we have to clean just created SSL context manually, thus appropriate call added. Additionally, ngx_pool_cleanup_add() moved closer to ngx_ssl_create() in the ngx_http_ssl_module, to make sure there are no leaks due to intermediate code.
2018-10-03Upstream: proxy_socket_keepalive and friends.Vladimir Homutov1-0/+11
The directives enable the use of the SO_KEEPALIVE option on upstream connections. By default, the value is left unchanged.
2018-07-17Fixed invalid access to location defined as an empty string.Ruslan Ermilov1-1/+1
2018-07-17SSL: save sessions for upstream peers using a callback function.Sergey Kandaurov1-0/+7
In TLSv1.3, NewSessionTicket messages arrive after the handshake and can come at any time. Therefore we use a callback to save the session when we know about it. This approach works for < TLSv1.3 as well. The callback function is set once per location on merge phase. Since SSL_get_session() in BoringSSL returns an unresumable session for TLSv1.3, peer save_session() methods have been updated as well to use a session supplied within the callback. To preserve API, the session is cached in c->ssl->session. It is preferably accessed in save_session() methods by ngx_ssl_get_session() and ngx_ssl_get0_session() wrappers.
2018-05-07Silenced -Wcast-function-type warnings (closes #1546).Sergey Kandaurov1-1/+2
Cast to intermediate "void *" to lose compiler knowledge about the original type and pass the warning. This is not a real fix but rather a workaround. Found by gcc8.
2018-03-19Upstream: fixed comments after 13f8dec720b5.Ruslan Ermilov1-2/+2
The fields "uri", "location", and "url" from ngx_http_upstream_conf_t moved to ngx_http_proxy_loc_conf_t and ngx_http_proxy_vars_t, reflect this change in create_loc_conf comments.
2018-02-28Generic subrequests in memory.Roman Arutyunyan1-30/+0
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.
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-20Proxy: simplified conditions of using unparsed uri.Roman Arutyunyan1-4/+2
Previously, the unparsed uri was explicitly allowed to be used only by the main request. However the valid_unparsed_uri flag is nonzero only in the main request, which makes the main request check pointless.
2017-08-01Variables: macros for null variables.Ruslan Ermilov1-1/+1
No functional changes.
2017-03-15Proxy: split configured header names and values.Piotr Sikora1-106/+59
Previously, each configured header was represented in one of two ways, depending on whether or not its value included any variables. If the value didn't include any variables, then it would be represented as as a single script that contained complete header line with HTTP/1.1 delimiters, i.e.: "Header: value\r\n" But if the value included any variables, then it would be represented as a series of three scripts: first contained header name and the ": " delimiter, second evaluated to header value, and third contained only "\r\n", i.e.: "Header: " "$value" "\r\n" This commit changes that, so that each configured header is represented as a series of two scripts: first contains only header name, and second contains (or evaluates to) only header value, i.e.: "Header" "$value" or "Header" "value" This not only makes things more consistent, but also allows header name and value to be accessed separately. Signed-off-by: Piotr Sikora <piotrsikora@google.com>
2017-05-18Upstream: fixed u->headers_in.headers allocation error handling.Sergey Kandaurov1-0/+1
Previously, an allocation error resulted in uninitialized memory access when evaluating $upstream_http_ variables. On a related note, see r->headers_out.headers cleanup work in 0cdee26605f3.
2017-04-18SSL: added support for TLSv1.3 in ssl_protocols directive.Sergey Kandaurov1-0/+1
Support for the TLSv1.3 protocol will be introduced in OpenSSL 1.1.1.
2017-03-24Upstream: allow recovery from "429 Too Many Requests" response.Piotr Sikora1-0/+1
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-02-10Upstream: proxy_cache_background_update and friends.Roman Arutyunyan1-0/+11
The directives enable cache updates in subrequests.
2016-11-02Cache: proxy_cache_max_range_offset and friends.Dmitry Volyntsev1-0/+12
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-10-31Upstream: added the ngx_http_upstream_resolved_t.name field.Ruslan Ermilov1-4/+2
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 Ermilov1-1/+1
The first condition added in d3454e719bbb should have just replaced the second one.
2016-10-16Proxy: support variables for proxy_method directive.Dmitry Lazurkin1-6/+10
2016-10-14Upstream: handling of proxy_set_header at http level.Maxim Dounin1-0/+14
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-06-15SSL: ngx_ssl_ciphers() to set list of ciphers.Tim Taubert1-6/+2
This patch moves various OpenSSL-specific function calls into the OpenSSL module and introduces ngx_ssl_ciphers() to make nginx more crypto-library-agnostic.
2015-12-18Upstream: the "transparent" parameter of proxy_bind and friends.Roman Arutyunyan1-1/+1
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-03-31Fixed logging.Sergey Kandaurov1-4/+4
2016-03-28Upstream: proxy_next_upstream non_idempotent.Maxim Dounin1-0/+1
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".
2015-11-06Proxy: improved code readability.Ruslan Ermilov1-12/+5
Do not assume that space character follows the method name, just pass it explicitly. The fuss around it has already proved to be unsafe, see bbdb172f0927 and http://mailman.nginx.org/pipermail/nginx-ru/2013-January/049692.html for details.
2015-11-21Upstream: fixed "no port" detection in evaluated upstreams.Ruslan Ermilov1-2/+3
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-0/+11
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-05-25Disabled SSLv3 by default (ticket #653).Maxim Dounin1-3/+2
2015-03-26Proxy: fixed proxy_request_buffering and chunked with preread body.Maxim Dounin1-3/+4
If any preread body bytes were sent in the first chain, chunk size was incorrectly added before the whole chain, including header, resulting in an invalid request sent to upstream. Fixed to properly add chunk size after the header.
2015-03-23Proxy: proxy_request_buffering chunked support.Maxim Dounin1-6/+216
2015-03-23Request body: unbuffered reading.Maxim Dounin1-1/+25
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-23Proxy: fixed proxy_set_body with proxy_cache.Maxim Dounin1-0/+1
If the last header evaluation resulted in an empty header, the e.skip flag was set and was not reset when we've switched to evaluation of body_values. This incorrectly resulted in body values being skipped instead of producing some correct body as set by proxy_set_body. Fix is to properly reset the e.skip flag. As the problem only appeared if the last potentially non-empty header happened to be empty, it only manifested itself if proxy_set_body was used with proxy_cache.
2015-03-04Proxy: use an appropriate error on memory allocation failure.Ruslan Ermilov1-1/+1
2014-12-22Upstream: added variables support to proxy_cache and friends.Valentin Bartenev1-8/+70
2014-12-22Upstream: refactored proxy_cache and friends.Valentin Bartenev1-19/+20
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: mutually exclusive inheritance of "cache" and "store".Valentin Bartenev1-0/+14
Currently, storing and caching mechanisms cannot work together, and a configuration error is thrown when the proxy_store and proxy_cache directives (as well as their friends) are configured on the same level. But configurations like in the example below were allowed and could result in critical errors in the error log: proxy_store on; location / { proxy_cache one; } Only proxy_store worked in this case. For more predictable and errorless behavior these directives now prevent each other from being inherited from the previous level.
2014-12-22Upstream: simplified proxy_store and friends configuration code.Valentin Bartenev1-9/+6
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-10-09Upstream: fixed inheritance of proxy_store and friends.Valentin Bartenev1-1/+1
The proxy_store, fastcgi_store, scgi_store and uwsgi_store were inherited incorrectly if a directive with variables was defined, and then redefined to the "on" value, i.e. in configurations like: proxy_store /data/www$upstream_http_x_store; location / { proxy_store on; }
2014-12-09Proxy: fixed incorrect URI change due to if (ticket #86).Maxim Dounin1-1/+1
In the following configuration request was sent to a backend without URI changed to '/' due to if: location /proxy-pass-uri { proxy_pass http://127.0.0.1:8080/; set $true 1; if ($true) { # nothing } } Fix is to inherit conf->location from the location where proxy_pass was configured, much like it's done with conf->vars.
2014-12-09Upstream: fixed unexpected inheritance into limit_except blocks.Maxim Dounin1-7/+10
The proxy_pass directive and other handlers are not expected to be inherited into nested locations, but there is a special code to inherit upstream handlers into limit_except blocks, as well as a configuration into if{} blocks. This caused incorrect behaviour in configurations with nested locations and limit_except blocks, like this: location / { proxy_pass http://u; location /inner/ { # no proxy_pass here limit_except GET { # nothing } } } In such a configuration the limit_except block inside "location /inner/" unexpectedly used proxy_pass defined in "location /", while it shouldn't. Fix is to avoid inheritance of conf->upstream.upstream (and conf->proxy_lengths) into locations which don't have noname flag.
2014-12-09Upstream: inheritance of proxy_pass and friends (ticket #645).Maxim Dounin1-9/+5
Instead of independant inheritance of conf->upstream.upstream (proxy_pass without variables) and conf->proxy_lengths (proxy_pass with variables) we now test them both and inherit only if neither is set. Additionally, SSL context is also inherited only in this case now. Based on the patch by Alexey Radkov.
2014-12-09Proxy: the "TE" header now stripped by default (ticket #537).Maxim Dounin1-0/+2
2014-11-19Proxy: renamed and rearranged fields in proxy configuration.Roman Arutyunyan1-16/+15
No functional changes.
2014-11-19Upstream: different header lists for cached and uncached requests.Roman Arutyunyan1-19/+33
The upstream modules remove and alter a number of client headers before sending the request to upstream. This set of headers is smaller or even empty when cache is disabled. It's still possible that a request in a cache-enabled location is uncached, for example, if cache entry counter is below min_uses. In this case it's better to alter a smaller set of headers and pass more client headers to backend unchanged. One of the benefits is enabling server-side byte ranges in such requests.
2014-11-19Upstream: moved header lists to separate structures.Roman Arutyunyan1-40/+49
No functional changes.
2014-11-19Upstream: moved header initializations to separate functions.Roman Arutyunyan1-20/+19
No functional changes.