Yann Ylavic [Fri, 15 Oct 2021 11:09:32 +0000 (11:09 +0000)]
mod_proxy_connect: Honor the smallest of the backend or client timeout.
It seems that mod_proxy_connect has never applied any timeout in its tunneling
loop. Address this by setting a default timeout in ap_proxy_tunnel_create()
since mod_proxy_connect does not overwrite tunnel->timeout (while proxy_http
and proxy_wstunnel do).
This default timeout is set to the smallest of the backend side or the client
side timeout.
Yann Ylavic [Fri, 15 Oct 2021 10:29:00 +0000 (10:29 +0000)]
mpm_event: Restart stopping of idle children after a load peak. PR 65626.
r1770752 added an heuristic to avoid stopping children when the load triggers
MaxSpareThreads but children take some time to shut down until the point where
active_daemons_limit/ServerLimit is reached (scoreboard full) and no child gets
created to handle incoming connections.
However when this happens there is nothing to stop children again when the load
settles down (besides MaxRequestsPerChild, which may be 0) so let's restart to
stop children again if/when idle_thread_count reaches max_workers / 4.
Stefan Eissing [Thu, 14 Oct 2021 10:18:17 +0000 (10:18 +0000)]
*) mod_http2: when pollset signals output, resume a streams data
in nghttp2 every time without checks that response body bytes
are available. This resolves the situation that a stream may stall
when 2 consecutive H2HEADER buckets are sent (e.g. 103+200).
Stefan Eissing [Thu, 14 Oct 2021 09:58:37 +0000 (09:58 +0000)]
*) mod_http2: H2HEADER buckets have the correct lenght of zero and no
longer smuggle the contained field lengths in this field. Instead
the bytes reportded to mod_logio are counted specifically.
Stefan Eissing [Thu, 14 Oct 2021 08:59:12 +0000 (08:59 +0000)]
*) mod_http2: no longer splitting buckets on adding them to a beam,
accepting the whole bucket since no memory is saved by a split.
Also, allowing meta buckets to be added to a "full" beam.
Re-enabled test cases for travis verification.
Stefan Eissing [Wed, 13 Oct 2021 12:26:21 +0000 (12:26 +0000)]
* mod_http2: resurrecting check for nghttp function
nghttp2_session_callbacks_set_on_invalid_header_callback
adding test for proxy server header behaviour
making test fixture package scoped for better performance
Stefan Eissing [Wed, 13 Oct 2021 11:15:03 +0000 (11:15 +0000)]
* mod_http2: checking for nghttp2 function 'set_no_closed_streams' on configure.
adapting test result expectations for new nghttp2 1.45 change in checking
pseudo header fields for invalid characters.
Yann Ylavic [Tue, 12 Oct 2021 16:48:18 +0000 (16:48 +0000)]
*) core: Be safe with ap_lingering_close() called with a socket NULL-ed.
PR 65627.
mod_itk seems to:
ap_set_core_module_config(c->conn_config, NULL)
before calling ap_lingering_close(), causing a crash after r1891721.
Until we have an API to no-op ap_lingering_close(), let's be safe.
* server/connection.c(ap_start_lingering_close):
The socket should not be NULL here, add an assertion.
* server/connection.c(ap_lingering_close):
Set c->aborted if the socket is NULL, and give up.
Stefan Eissing [Tue, 12 Oct 2021 13:34:01 +0000 (13:34 +0000)]
*) mod_http2:
- Fixed an issue since 1.15.24 that "Server" headers in proxied requests
were overwritten instead of preserved. [PR by @daum3ns]
- Added directove 'H2StreamTimeout' to configure a separate value for HTTP/2
streams, overriding server's 'Timeout' configuration. [rpluem]
- HTTP/2 connections now use pollsets to monitor the status of the
ongoing streams and their main connection when host OS allows this.
- Removed work-arounds for older versions of libnghttp2 and checking
during configure that at least version 1.15.0 is present.
- The HTTP/2 connection state handler, based on an experiment and draft
at the IETF http working group (abandoned for some time), has been removed.
- H2SerializeHeaders no longer has an effect. A warning is logged when it is
set to "on". The switch enabled the internal writing of requests to be parsed
by the internal HTTP/1.1 protocol handler and was introduced to avoid
potential incompatibilities during the introduction of HTTP/2.
- Removed the abort/redo of tasks when mood swings lower the active limit.
Stefan Eissing [Mon, 11 Oct 2021 14:08:57 +0000 (14:08 +0000)]
* test infrastruture:
- moved common pytest code into test/pyhttpd
- does basic setup for a list of host names and some htdocs
- added modules/core and moved encoding tests from http2 there
- all test methods have module name in in prefix now, so to test only core, run
> pytest -k test_core
Yann Ylavic [Sat, 9 Oct 2021 15:22:00 +0000 (15:22 +0000)]
mod_proxy_uwsgi: Remove duplicate slashes at the beginning of PATH_INFO.
To accommodate for configs like:
ProxyPass /uwsgi-pp uwsgi://localhost:8001/
which before r1892805 did not produce a leading double-slash in PATH_INFO.
Ruediger Pluem [Fri, 8 Oct 2021 10:49:06 +0000 (10:49 +0000)]
* Make aliases more robust against potential traversal attacks, by using
apr_filepath_merge to merge the real path and the remainder of the fake
path like we do in the same situation for resources mapped by
DocumentRoot.
Joe Orton [Thu, 7 Oct 2021 10:17:27 +0000 (10:17 +0000)]
* modules/ssl/ssl_engine_init.c (ssl_init_ctx_callbacks,
ssl_init_server_certs): Flip logic for enabling/disabling DH auto
parameter selection for OpenSSL 1.1+ to be simpler and consistent
with auto ECDH curve selection.
Joe Orton [Mon, 4 Oct 2021 10:26:18 +0000 (10:26 +0000)]
* modules/ssl/ssl_engine_init.c (ssl_init_server_certs): For OpenSSL
1.1+, disable auto DH parameter selection if parameters have been
manually configured. This fixes a regression in r1890067 after
which manually configured parameters are ignored.
* modules/proxy/mod_proxy.h, modules/proxy/mod_proxy.c:
Declare/implement the hook.
* modules/proxy/proxy_util.c(proxy_transfer):
Run tunnel_forward hooks when called by the tunneling loop.
Simpler input/output brigade cleanup on exit.
* modules/proxy/mod_proxy.h,modules/proxy/proxy_util.c:
Add ap_proxy_fill_error_brigade() to factorize proxy error handling
on the client connection side.
* modules/proxy/mod_proxy_{http,ajp,uwsgi}.c:
Use ap_proxy_fill_error_brigade() where needed, including when an
empty brigade is returned on the backend side or when calling
ap_proxy_buckets_lifetime_transform fails.
* modules/proxy/mod_proxy.h:
Restore the interface of ap_proxy_transfer_between_connections() back to
before MMN 20210506.0.
Add ap_proxy_tunnel_conn_bytes_in() and ap_proxy_tunnel_conn_bytes_out().
New proxy_tunnel_conn_t typedef'ed from opaque struct proxy_tunnel_conn.
* modules/proxy/mod_proxy.h(ap_proxy_tunnel_conn_get_read,
ap_proxy_tunnel_conn_get_transferred):
Axed/replaced by ap_proxy_tunnel_conn_bytes_in() and
ap_proxy_tunnel_conn_bytes_out().
* modules/proxy/proxy_util.c(struct proxy_tunnel_conn):
Replace "exchanged" by "bytes_in" and "bytes_out".
* modules/proxy/proxy_util.c(proxy_transfer):
New helper implementing ap_proxy_transfer_between_connections() and
returning both &bytes_in and &bytes_out.
* modules/proxy/proxy_util.c(ap_proxy_transfer_between_connections):
Now calls proxy_transfer().
* modules/proxy/proxy_util.c(ap_proxy_tunnel_conn_bytes_in,
ap_proxy_tunnel_conn_bytes_out):
Return tc->bytes_in and tc->bytes_out respectively.
* modules/proxy/proxy_util.c(proxy_tunnel_forward):
Use proxy_transfer() which updates in->bytes_in, &out->bytes_out.
tunnel->replied will be updated in proxy_tunnel_run().
* modules/proxy/proxy_util.c(proxy_tunnel_forward):
Fall through the "done" label in any case to set tunnel->replied based
on tunnel->client->bytes_out > 0.
* modules/proxy/mod_proxy_http.c(ap_proxy_http_process_response):
Use ap_proxy_tunnel_conn_bytes_{in,out}() for worker->s->{read,transferred}
accounting.
* modules/proxy/mod_proxy_http.c(proxy_http_async_finish):
Update worker->s->{read,transferred} when async too.
Stefan Eissing [Thu, 23 Sep 2021 13:44:58 +0000 (13:44 +0000)]
* mod_http2: fix version suffix after sync with github
Make shutdown worker wait loop robust against timed wait
interruptions and report the correct seconds waited.
* t/modules/http2.t is gone since 1893547. So do not use it any longer in
HTTP/2 tests and remove the dependency on Protocol::HTTP2::Client.
Update test/travis_run_linux.sh to handle NO_TEST_FRAMEWORK.
mod_proxy: Handle UDS URIs with empty hostname as if they had no hostname.
It was reported to me (privately) that r1893101 broke existing settings like:
SetHandler "proxy:unix:///path/to/uds.sock|fcgi://localhost/"
RFC 3986 (section 3.2.2) says that:
If the URI scheme defines a default for host, then that default
applies when the host subcomponent is undefined or when the
registered name is empty (zero length). For example, the "file" URI
scheme is defined so that no authority, an empty host, and
"localhost" all mean the end-user's machine, whereas the "http"
scheme considers a missing authority or empty host invalid.
Let's consider that the "unix" scheme is closer to the "file" scheme than
the "http" one, and accept "unix:///path/to/uds.sock" as a valid URI.
Handle the unix: scheme as an obsolute URI or a rule like:
RewriteRule ^/(.*) unix:/path/to/uds.sock|fcgi://localhost/$1 [P]
sets r->filename for /index.html as:
proxy:http://www.example.com/unix:/path/to/uds.sock|http://localhost/index.html
instead of the expected:
proxy:unix:/path/to/uds.sock|http://localhost/index.html
Submitted by: Janne Peltonen <janne.peltonen sange.fi>
Reviewed by: ylavic
In case one of the pre_connection hooks causes the hook run to stop by an error
the pre_connection hook of the core module maybe did not run
(it is APR_HOOK_REALLY_LAST) and hence we missed to
- Put the socket in c->conn_config
- Setup core output and input filters
- Set socket options and timeouts
For calls of ap_run_pre_connection where this matters create a wrapper named
ap_pre_connection that ensures that this happens.
* include/ap_mmn.h: Bump minor version as we added new ap_pre_connection
function.
idle_spawn_rate *= 2 can go above MAX_SPAWN_RATE at some point, and it's not
enough for MAX_SPAWN_RATE to be a power of two for MPMs event and worker since
idle_spawn_rate is per bucket (num_buckets is not necessarily a power of two).
Let's cap on the other MPMs too should MAX_SPAWN_RATE change in the future.
Stefan Eissing [Fri, 17 Sep 2021 12:18:41 +0000 (12:18 +0000)]
*) mod_md: when MDMessageCmd for a 'challenge-setup:<type>:<dnsname>'
fails (!= 0 exit), the renewal process is aborted and an error is
reported for the MDomain. This provides scripts that distribute
information in a cluster to abort early with bothering an ACME
server to validate a dns name that will not work. The common
retry logic will make another attempt in the future, as with
other failures.
Fixed a bug when adding private key specs to an already working
MDomain, see <https://github.com/icing/mod_md/issues/260>.
Stefan Eissing [Wed, 15 Sep 2021 13:22:27 +0000 (13:22 +0000)]
*) mod_md: fixed a bug in handling multiple parallel OCSP requests. These could
run into an assertion which terminated (and restarted) the child process where
the task was running. Eventually, all OCSP responses were collected, but not
in the way that things are supposed to work.
See also <https://bz.apache.org/bugzilla/show_bug.cgi?id=65567>.
The bug was possibly triggered when more than one OCSP status needed updating
at the same time. For example for several renewed certificates after a server
reload.