aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_scgi_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).
* SCGI: added create_loc_conf comments.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.
* SCGI: combining headers with identical names (ticket #1724).Maxim Dounin2022-05-30
| | | | | | | | | | | | SCGI specification explicitly forbids headers with duplicate names (section "3. Request Format"): "Duplicate names are not allowed in the headers". Further, provided headers are expected to follow CGI specification, which also requires to combine headers (RFC 3875, section "4.1.18. Protocol-Specific Meta-Variables"): "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.
* Upstream: drop extra data sent by upstream.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. This change covers generic buffered and unbuffered filters as used in the scgi and uwsgi modules. Appropriate input filter init handlers are provided by the scgi and uwsgi modules to set corresponding lengths. Note that for responses to HEAD requests there is an exception: we do allow any response length. This is because responses to HEAD requests might be actual full responses, and it is up to nginx to remove the response body. If caching is enabled, only full responses matching the Content-Length header will be cached (see b779728b180c).
* 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.
* Style.Maxim Dounin2017-08-10
|
* 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;
* 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.
* Upstream: uwsgi_request_buffering, scgi_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.
* Scgi: do not push redundant NULL element into conf->params.Roman Arutyunyan2014-11-19
|
* 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.
* 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.
* Style.Maxim Dounin2014-09-11
|
* Style: remove whitespace between function name and parentheses.Piotr Sikora2014-07-08
| | | | Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
* Upstream: cache revalidation using If-None-Match.Maxim Dounin2014-06-26
|
* Upstream: fix $upstream_status variable.Piotr Sikora2014-02-11
| | | | | | | | Previously, upstream's status code was overwritten with cached response's status code when STALE or REVALIDATED response was sent to the client. Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
* Style: removed surplus semicolons.Valentin Bartenev2013-12-27
|
* Upstream: skip empty cache headers.Maxim Dounin2013-11-29
| | | | | Notably this fixes HTTP_IF_MODIFIED_SINCE which was always sent with cache enabled in fastcgi/scgi/uwsgi after 43ccaf8e8728.
* Upstream: cache revalidation with conditional requests.Maxim Dounin2013-11-18
| | | | | | | | | | | | The following new directives are introduced: proxy_cache_revalidate, fastcgi_cache_revalidate, scgi_cache_revalidate, uwsgi_cache_revalidate. Default is off. When set to on, they enable cache revalidation using conditional requests with If-Modified-Since for expired cache items. As of now, no attempts are made to merge headers given in a 304 response during cache revalidation with headers previously stored in a cache item. Headers in a 304 response are only used to calculate new validity time of a cache item.
* Upstream: subrequest_in_memory support for SCGI and uwsgi enabled.Maxim Dounin2013-09-27
| | | | | This was missed in 9d59a8eda373 when non-buffered support was added to SCGI and uwsgi.
* Upstream: http_403 support in proxy_next_upstream (and friends).Maxim Dounin2013-05-27
| | | | | | | | | The parameter is mostly identical to http_404, and is expected to be used in similar situations. The 403 code might be returned by a backend instead of 404 on initial sync of new directories with rsync. See here for feature request and additional details: http://mailman.nginx.org/pipermail/nginx-ru/2013-April/050920.html