aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_fastcgi_module.c
Commit message (Collapse)AuthorAge
* Upstream: disallow empty path in proxy_store and friends.Sergey Kandaurov2024-11-25
| | | | | | | | | | | | | | | | | | | | Renaming a temporary file to an empty path ("") returns NGX_ENOPATH with a subsequent ngx_create_full_path() to create the full path. This function skips initial bytes as part of path separator lookup, which causes out of bounds access on short strings. The fix is to avoid renaming a temporary file to an obviously invalid path, as well as explicitly forbid such syntax for literal values. Although Coverity reports about potential type underflow, it is not actually possible because the terminating '\0' is always included. Notably, the run-time check is sufficient enough for Win32 as well. Other short invalid values result either in NGX_ENOENT or NGX_EEXIST and "MoveFile() .. failed" critical log messages, which involves a separate error handling. Prodded by Coverity (CID 1605485).
* FastCGI: fixed create_loc_conf comments after 05b1a8f1e.Sergey Kandaurov2024-11-12
|
* Upstream: variables support in proxy_limit_rate and friends.J Carter2023-11-25
|
* Upstream: fixed handling of Status headers without reason-phrase.Maxim Dounin2023-08-31
| | | | | | | | | | | | | | Status header with an empty reason-phrase, such as "Status: 404 ", is valid per CGI specification, but looses the trailing space during parsing. Currently, this results in "HTTP/1.1 404" HTTP status line in the response, which violates HTTP specification due to missing trailing space. With this change, only the status code is used from such short Status header lines, so nginx will generate status line itself, with the space and appropriate reason phrase if available. Reported at: https://mailman.nginx.org/pipermail/nginx/2023-August/EX7G4JUUHJWJE5UOAZMO5UD6OJILCYGX.html
* Upstream: header handlers can now return parsing errors.Maxim Dounin2022-05-30
| | | | | | | With this change, duplicate Content-Length and Transfer-Encoding headers are now rejected. Further, responses with invalid Content-Length or Transfer-Encoding headers are now rejected, as well as responses with both Content-Length and Transfer-Encoding.
* FastCGI: combining headers with identical names (ticket #1724).Maxim Dounin2022-05-30
| | | | | | | | | | | | FastCGI responder is expected to receive CGI/1.1 environment variables in the parameters (see section "6.2 Responder" of the FastCGI specification). Obviously enough, there cannot be multiple environment variables with the same name. Further, CGI specification (RFC 3875, section "4.1.18. Protocol-Specific Meta-Variables") explicitly requires to combine headers: "If multiple header fields with the same field-name are received then the server MUST rewrite them as a single value having the same semantics".
* Upstream: fixed logging level of upstream invalid header errors.Maxim Dounin2021-10-18
| | | | | | | In b87b7092cedb (nginx 1.21.1), logging level of "upstream sent invalid header" errors was accidentally changed to "info". This change restores the "error" level, which is a proper logging level for upstream-side errors.
* Improved logging of invalid headers.Maxim Dounin2021-06-28
| | | | | | | | | | | | | | In 71edd9192f24 logging of invalid headers which were rejected with the NGX_HTTP_PARSE_INVALID_HEADER error was restricted to just the "client sent invalid header line" message, without any attempts to log the header itself. This patch returns logging of the header up to the invalid character and the character itself. The r->header_end pointer is now properly set in all cases to make logging possible. The same logging is also introduced when parsing headers from upstream servers.
* FastCGI: fixed zero size buf alerts on extra data (ticket #2018).Maxim Dounin2020-07-27
| | | | | | After 05e42236e95b (1.19.1) responses with extra data might result in zero size buffers being generated and "zero size buf" alerts in writer (if f->rest happened to be 0 when processing additional stdout data).
* FastCGI: protection from responses with wrong length.Maxim Dounin2020-07-06
| | | | | | | | | | | | | | | 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. Additionally, we now also issue a warning if the response is too short, and make sure the fact it is truncated is propagated to the client. The u->error flag is introduced to make it possible to propagate the error to the client in case of unbuffered proxying. For responses to HEAD requests there is an exception: we do allow both responses without body and responses with body matching the Content-Length header.
* Upstream: proxy_socket_keepalive and friends.Vladimir Homutov2018-10-03
| | | | | The directives enable the use of the SO_KEEPALIVE option on upstream connections. By default, the value is left unchanged.
* Fixed invalid access to location defined as an empty string.Ruslan Ermilov2018-07-17
|
* Silenced -Wcast-function-type warnings (closes #1546).Sergey Kandaurov2018-05-07
| | | | | | | 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.
* Upstream: fixed comments after 13f8dec720b5.Ruslan Ermilov2018-03-19
| | | | | | 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.
* Generic subrequests in memory.Roman Arutyunyan2018-02-28
| | | | | | | | | | | 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.
* FastCGI: adjust buffer position when parsing incomplete records.Maxim Dounin2017-11-09
| | | | | | | | | | | | | | | | | | Previously, nginx failed to move buffer position when parsing an incomplete record header, and due to this wasn't be able to continue parsing once remaining bytes of the record header were received. This can affect response header parsing, potentially generating spurious errors like "upstream sent unexpected FastCGI request id high byte: 1 while reading response header from upstream". While this is very unlikely, since usually record headers are written in a single buffer, this still can happen in real life, for example, if a record header will be split across two TCP packets and the second packet will be delayed. This does not affect non-buffered response body proxying, due to "buf->pos = buf->last;" at the start of the ngx_http_fastcgi_non_buffered_filter() function. Also this does not affect buffered response body proxying, as each input buffer is only passed to the filter once.
* Variables: macros for null variables.Ruslan Ermilov2017-08-01
| | | | No functional changes.
* Upstream: fixed u->headers_in.headers allocation error handling.Sergey Kandaurov2017-05-18
| | | | | | | 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.
* Upstream: allow recovery from "429 Too Many Requests" response.Piotr Sikora2017-03-24
| | | | | | | | 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>
* Upstream: proxy_cache_background_update and friends.Roman Arutyunyan2017-02-10
| | | | The directives enable cache updates in subrequests.
* Cache: proxy_cache_max_range_offset and friends.Dmitry Volyntsev2016-11-02
| | | | | | 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.
* Upstream: added the ngx_http_upstream_resolved_t.name field.Ruslan Ermilov2016-10-31
| | | | | | | | | | | | | | | | | | | | | | 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.
* Upstream: removed unnecessary condition in proxy_eval() and friends.Ruslan Ermilov2016-10-31
| | | | | The first condition added in d3454e719bbb should have just replaced the second one.
* Upstream: handling of proxy_set_header at http level.Maxim Dounin2016-10-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.
* Upstream: the "transparent" parameter of proxy_bind and friends.Roman Arutyunyan2015-12-18
| | | | | | | | | | | 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;
* FastCGI: skip special bufs in buffered request body chain.Valentin Bartenev2016-04-11
| | | | | | | | | | | This prevents forming empty records out of such buffers. Particularly it fixes double end-of-stream records with chunked transfer encoding, or when HTTP/2 is used and the END_STREAM flag has been sent without data. In both cases there is an empty buffer at the end of the request body chain with the "last_buf" flag set. The canonical libfcgi, as well as php implementation, tolerates such records, while the HHVM parser is more strict and drops the connection (ticket #950).
* Fixed logging.Sergey Kandaurov2016-03-31
|
* Style.Ruslan Ermilov2016-03-30
|
* Upstream: proxy_next_upstream non_idempotent.Maxim Dounin2016-03-28
| | | | | | | 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".
* Upstream: fixed "no port" detection in evaluated upstreams.Ruslan Ermilov2015-11-21
| | | | | | 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.
* Win32: MSVC 2015 compatibility.Maxim Dounin2015-08-17
| | | | | | | Resolved warnings about declarations that hide previous local declarations. Warnings about WSASocketA() being deprecated resolved by explicit use of WSASocketW() instead of WSASocket(). When compiling without IPv6 support, WinSock deprecated warnings are disabled to allow use of gethostbyname().
* FastCGI: fastcgi_request_buffering.Maxim Dounin2015-03-23
|
* Upstream: added variables support to proxy_cache and friends.Valentin Bartenev2014-12-22
|
* 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: mutually exclusive inheritance of "cache" and "store".Valentin Bartenev2014-12-22
| | | | | | | | | | | | | | | | | | | | 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.
* 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.
* Upstream: fixed inheritance of proxy_store and friends.Valentin Bartenev2014-10-09
| | | | | | | | | | | | 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; }
* Upstream: fixed unexpected inheritance into limit_except blocks.Maxim Dounin2014-12-09
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Upstream: inheritance of proxy_pass and friends (ticket #645).Maxim Dounin2014-12-09
| | | | | | | | | 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.
* Upstream: different header lists for cached and uncached requests.Roman Arutyunyan2014-11-19
| | | | | | | | | | | | 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.
* Upstream: moved header lists to separate structures.Roman Arutyunyan2014-11-19
| | | | No functional changes.
* Upstream: moved header initializations to separate functions.Roman Arutyunyan2014-11-19
| | | | No functional changes.
* 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: 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.
* 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.
* FastCGI: fixed start pointers in request buffers.Roman Arutyunyan2014-09-18
| | | | | The start pointers are used in ngx_http_upstream_reinit() to reinit FastCGI requests.
* 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.
* Added warning about unset cache keys.Maxim Dounin2014-09-11
| | | | | In fastcgi, scgi and uwsgi modules there are no default cache keys, and using a cache without a cache key set is likely meaningless.
* Upstream: cache revalidation using If-None-Match.Maxim Dounin2014-06-26
|
* FastCGI: f->split_parts reset on request start.Maxim Dounin2014-03-17
| | | | | | | | Additionally, make sure to check for errors from ngx_http_parse_header_line() call after joining saved parts. There shouldn't be any errors, though check may help to catch bugs like missing f->split_parts reset. Reported by Lucas Molas.