1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-07 04:02:58 +03:00

103 Commits

Author SHA1 Message Date
Yann Ylavic
3c7f67fa2a mod_proxy: Handle backend address renewal with address_ttl= parameter.
Define a new proxy_address struct holding the current/latest sockaddr in use
by each proxy worker and conn. Since backend addresses can be updated when
their TTL expires and while connections are being processed, each address is
refcounted and freed only when the last worker (or conn) using it grabs the
new one.

The lifetime of the addresses is handled at a single place by the new
ap_proxy_determine_address() function. It guarantees to bind the current/latest
backend address to the passed in conn (or do nothing if it's up to date already).
The function is called indirectly by ap_proxy_determine_connection() for the
proxy modules that use it, or directly by mod_proxy_ftp and mod_proxy_hcheck.
It also is called eventually by ap_proxy_connect_backend() when connect()ing all
the current addresses fails, to check (PROXY_DETERMINE_ADDRESS_CHECK) if some
new addrs are available.

This commit is also a rework of the lifetime of conn->addr, conn->hostname
and conn->forward, using the conn->uds_pool and conn->fwd_pool for the cases
where the backend is connected through a UDS socket and a remote CONNECT proxy
respectively.

* include/ap_mmn.h:
  Minor bump for new function/fields.

* modules/proxy/mod_proxy.h (struct proxy_address,
                             ap_proxy_determine_addresss()):
  Declare ap_proxy_determine_addresss() and opaque struct proxy_address,
  new fields to structs proxy_conn_rec/proxy_worker_shared/proxy_worker.

* modules/proxy/mod_proxy.c (set_worker_param):
  Parse/set the new worker->address_ttl parameter.

* modules/proxy/proxy_util.c (proxy_util_register_hooks(),
                              ap_proxy_initialize_worker(),
                              ap_proxy_connection_reusable(),
                              ap_proxyerror(), proxyerror_core(),
                              init_conn_pool(), make_conn_subpool(),
                              connection_make(), connection_cleanup(),
                              connection_constructor()):
 Initialize *proxy_start_time in proxy_util_register_hooks() as the epoch
 from which expiration times are relative (i.e. seconds stored in an uint32_t
 for atomic changes).
 Make sure worker->s->is_address_reusable and worker->s->disablereuse are
 consistant in ap_proxy_initialize_worker(), thus no need to check for both
 in ap_proxy_connection_reusable().
 New proxyerror_core() helper taking an apr_status_t to log, wrap in
 ap_proxyerror().
 New make_conn_subpool() to create worker->cp->{pool,dns} with their own
 allocator.
 New connection_make() helper to factorize code in connection_cleanup() and
 connection_constructor().

* modules/proxy/proxy_util.c (proxy_address_inc(), proxy_address_dec(),
                              proxy_address_cleanup(), proxy_address_set_expired(),
                              worker_address_get(), worker_address_set(),
                              worker_address_resolve(), proxy_addrs_equal(),
                              ap_proxy_determine_address(),
                              ap_proxy_determine_connection(),
                              ap_proxy_connect_backend()):
 Implement ap_proxy_determine_address() using the above helpers for atomic changes,
 and call it from ap_proxy_determine_connection() and ap_proxy_connect_backend().

* modules/proxy/mod_proxy_ftp.c (proxy_ftp_handler):
  Use ap_proxy_determine_address() and use the returned backend->addr.

* modules/proxy/mod_proxy_hcheck.c (hc_determine_connection, hc_get_backend,
                                    hc_init_worker, hc_watchdog_callback):
  Use ap_proxy_determine_address() in hc_determine_connection() and call the
  latter from hc_get_backend(), replace hc_init_worker() by hc_init_baton()
  which now calls hc_get_hcworker() and hc_get_backend() to resolve the first
  address at init time.

* modules/proxy/mod_proxy_http.c (proxy_http_handler):
  Use backend->addr and ->hostname instead of worker->cp->addr and
  worker->s->hostname_ex respectively.

* modules/proxy/mod_proxy_ajp.c (ap_proxy_ajp_request):
  Use backend->addr and ->hostname instead of worker->cp->addr and
  worker->s->hostname_ex respectively.


Closes #367



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1912459 13f79535-47bb-0310-9956-ffa450edef68
2023-09-21 13:15:35 +00:00
Jim Jagielski
34773b7343 catch by CJ
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1904642 13f79535-47bb-0310-9956-ffa450edef68
2022-10-17 11:16:49 +00:00
Jim Jagielski
ac04f2ff6b *) mod_proxy_hcheck: Re-enable workers in standard ERROR state. PR 66302.
[Alessandro Cavaliere <alessandro.cavalier7 unibo.it>]


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1904518 13f79535-47bb-0310-9956-ffa450edef68
2022-10-11 13:20:11 +00:00
Jim Jagielski
093aa70e77 *) mod_proxy_hcheck: Detect AJP/CPING support correctly. PR 66300.
[Alessandro Cavaliere <alessandro.cavalier7 unibo.it>]




git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1904516 13f79535-47bb-0310-9956-ffa450edef68
2022-10-11 13:15:24 +00:00
Jim Jagielski
eb2325b125 Allow for HTTP/1.1 or HTTP/1.0 protocol health checks
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1903744 13f79535-47bb-0310-9956-ffa450edef68
2022-08-28 18:46:21 +00:00
Stefan Eissing
a4f45f275b *) core/mod_proxy/mod_ssl:
Adding `outgoing` flag to conn_rec, indicating a connection is
     initiated by the server to somewhere, in contrast to incoming
     connections from clients.
     Adding 'ap_ssl_bind_outgoing()` function that marks a connection
     as outgoing and is used by mod_proxy instead of the previous
     optional function `ssl_engine_set`. This enables other SSL
     module to secure proxy connections.
     The optional functions `ssl_engine_set`, `ssl_engine_disable` and
     `ssl_proxy_enable` are now provided by the core to have backward
     compatibility with non-httpd modules that might use them. mod_ssl
     itself no longer registers these functions, but keeps them in its
     header for backward compatibility.
     The core provided optional function wrap any registered function
     like it was done for `ssl_is_ssl`.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1890605 13f79535-47bb-0310-9956-ffa450edef68
2021-06-08 14:37:44 +00:00
Yann Ylavic
ab2b9dbfb7 mod_proxy_hcheck: Honor worker timeout settings.
Daniel reported on user@ that hc connections do not timeout according to
the worker's tumeout= configuration, this fixes it.

While at it, copy the other timeout settings too.

Reported by: dferradal


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1889936 13f79535-47bb-0310-9956-ffa450edef68
2021-05-16 17:04:55 +00:00
Jean-Frederic Clere
d1a7c6c936 Fix the fixed timeout, thanks Rüdiger.
And set the current_thread of the connection.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1887439 13f79535-47bb-0310-9956-ffa450edef68
2021-03-10 16:24:21 +00:00
Jean-Frederic Clere
f5fbe0f338 Add CPING to health check logic.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1887415 13f79535-47bb-0310-9956-ffa450edef68
2021-03-10 10:36:46 +00:00
Yann Ylavic
8da28a629e mod_proxy_hcheck: don't pile up health checks. PR 63010.
Prevent health checks from running for a worker until the last one is fully
finished, to avoid making things worse (memory growth, #connections, ..).

This is done by zeroing worker->s->updated before scheduling the worker in the
threadpool, and resetting the time when it's finished. The scheduler then does
nothing if worker->s->updated is zero.

Also, to save some apr_time_now() calls when !HC_USE_THREADS, *baton->now is
updated in the callback and reused by the scheduler.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1885691 13f79535-47bb-0310-9956-ffa450edef68
2021-01-19 14:16:44 +00:00
Jean-Frederic Clere
bdca42c7b5 wss also needs is_ssl.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1875579 13f79535-47bb-0310-9956-ffa450edef68
2020-03-24 16:20:18 +00:00
Eric Covener
6d43562a4a PR64140: Allow %{Content-Type} in health check expressions
Submitted By: Renier Velazco <renier.velazco upr.edu>
Commited By: covener

Github: closes #97



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1874616 13f79535-47bb-0310-9956-ffa450edef68
2020-02-28 13:02:05 +00:00
Jean-Frederic Clere
13eda4ae29 Set connectiontimeout for mod_proxy_hcheck.
Fix for https://issues.jboss.org/browse/JBCS-448


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1862014 13f79535-47bb-0310-9956-ffa450edef68
2019-06-24 16:29:22 +00:00
Yann Ylavic
975f5e1095 Follow up to r1859371: extend to other ap_proxy_connection_create[_ex]() users.
This function now now handles SSL reuse as well as the "proxy-request-hostname"
note (SNI), so let's also call it unconditionnaly in all proxy modules.

On the mod_ssl side, since this note has the lifetime of the connection, don't
reset/unset it during handshake (ssl_io_filter_handshake).


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1859422 13f79535-47bb-0310-9956-ffa450edef68
2019-05-17 08:42:17 +00:00
Yann Ylavic
2ff4af5a01 mod_proxy_hcheck: mute "run from watchdog" message.
This is way too verbose (every 100ms) to be logged at any LogLevel.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1853992 13f79535-47bb-0310-9956-ffa450edef68
2019-02-20 21:30:16 +00:00
Jean-Frederic Clere
364189331e Create the configure for mod_proxy_hcheck when used in BalancerMember.
PR 60757



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1853560 13f79535-47bb-0310-9956-ffa450edef68
2019-02-14 08:14:52 +00:00
Jim Jagielski
5133c75373 mod_proxy_hcheck: Fix issues with TCP health checks. PR 61499
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1840582 13f79535-47bb-0310-9956-ffa450edef68
2018-09-11 15:06:50 +00:00
Jim Jagielski
465d468d9e Update updated field at the start of the check rather than at the end.
Re: [Bug 62318] healthcheck

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1838937 13f79535-47bb-0310-9956-ffa450edef68
2018-08-24 19:29:44 +00:00
Yann Ylavic
98ca03954d mod_proxy_hcheck: take balancer's SSLProxy* directives into account.
mod_proxy_hcheck was missing the merge of SSLProxy* directives defined by
balancer with the ones of the VirtualHost.

Since ap_proxy_connection_create_ex() needs a merged r->per_dir_config to apply
the correct SSL configuration, let's split create_request_rec() in two:
- create_request_rec() to only initialize the non-connection fields and merge
  balancer->section_config into r->per_dir_config,
- set_request_connection() to associate the connection with the request once
  it's been created from the merged configuration of the minimal request.

The issue was reported on the users@ mailing list:
https://lists.apache.org/thread.html/895cf250104b081b789101b1086b71a26d9c337db7123c5a552b7c69@%3Cusers.httpd.apache.org%3E


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1836276 13f79535-47bb-0310-9956-ffa450edef68
2018-07-19 15:25:40 +00:00
Joe Orton
dd57f485f9 * modules/proxy/mod_proxy_hcheck.c (sctx_t, hc_create_config):
Remove unused bucket allocator created off pconf.
  Tag the subpool.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1832991 13f79535-47bb-0310-9956-ffa450edef68
2018-06-06 08:42:33 +00:00
Graham Leggett
fac7f995b0 mod_proxy: Provide an RFC1035 compliant version of the hostname in the
proxy_worker_shared structure. PR62085


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1824176 13f79535-47bb-0310-9956-ffa450edef68
2018-02-13 21:22:05 +00:00
Jim Jagielski
8dc841ea11 Fix remaining lint from ms capability for hchecks.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1805206 13f79535-47bb-0310-9956-ffa450edef68
2017-08-16 15:14:48 +00:00
Jim Jagielski
30923668d1 Allow finer control over hcheck intervals... minimum is whatever
the watchdog slice is.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1799437 13f79535-47bb-0310-9956-ffa450edef68
2017-06-21 13:21:18 +00:00
Jim Jagielski
3751183add suggestion from ylavic
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1789387 13f79535-47bb-0310-9956-ffa450edef68
2017-03-29 17:09:32 +00:00
Jim Jagielski
cf85d9f6e6 final tune and preventative coding
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1786009 13f79535-47bb-0310-9956-ffa450edef68
2017-03-08 16:31:05 +00:00
Jim Jagielski
053c3520fa Defensive
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1785871 13f79535-47bb-0310-9956-ffa450edef68
2017-03-07 19:10:19 +00:00
Jim Jagielski
3d822138b5 More granular logging
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1784275 13f79535-47bb-0310-9956-ffa450edef68
2017-02-24 13:04:49 +00:00
Jim Jagielski
d02badb296 Instead of thread-pools for each server/context, use a server-wide
top-level threadpool, which is more efficient.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1784228 13f79535-47bb-0310-9956-ffa450edef68
2017-02-24 04:49:38 +00:00
Jim Jagielski
13f6901c24 Since ProxyHC* values are per-server, we need to loop thru all per-server
contexts. No need for each server/vhost to have it's own watchdog instance,
however.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1784227 13f79535-47bb-0310-9956-ffa450edef68
2017-02-24 04:28:28 +00:00
Jim Jagielski
72d18f87f9 Use single top-level context and have the callback loop thru all servers/vhosts. Adjust server_rec
as required

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1784205 13f79535-47bb-0310-9956-ffa450edef68
2017-02-23 21:24:04 +00:00
Jim Jagielski
2501a90242 Work on all servers, not just top-level... Each Vhost has its own context and watchdog instance. We may need to revisit this and have just one instance
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1784203 13f79535-47bb-0310-9956-ffa450edef68
2017-02-23 20:54:47 +00:00
Yann Ylavic
2ddc069451 mod_proxy_hcheck: follow up to r1779574.
Parse/validate response bodies.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1779623 13f79535-47bb-0310-9956-ffa450edef68
2017-01-20 13:18:58 +00:00
Yann Ylavic
526ae59d90 mod_proxy_hcheck: Don't validate timed out responses.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1779574 13f79535-47bb-0310-9956-ffa450edef68
2017-01-20 08:30:00 +00:00
Yann Ylavic
632f491b62 mod_proxy_hcheck: thread-safety.
Use the thread pool everywhere for the needs/lifetime of the request to
the backend.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1779573 13f79535-47bb-0310-9956-ffa450edef68
2017-01-20 08:23:28 +00:00
Jim Jagielski
1bf31af8b6 Allow -DHC_USE_THREADS=0
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1779349 13f79535-47bb-0310-9956-ffa450edef68
2017-01-18 15:46:58 +00:00
Ruediger Pluem
f0c5598c8c * Add missing copy of hcuri and hcexpr ftom the worker to the health check worker.
PR: 60038
Submitted by: zdeno <zdeno@scnet.sk>


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1757662 13f79535-47bb-0310-9956-ffa450edef68
2016-08-25 11:38:07 +00:00
William A. Rowe Jr
2e2f089d45 Permit mod_proxy_hcheck.c to compile on Win32 32-bit architectures.
This decoration is required for all apr_thread fn() entry points,
at least on some platforms.



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1753777 13f79535-47bb-0310-9956-ffa450edef68
2016-07-22 12:28:54 +00:00
William A. Rowe Jr
f4cc76ee71 Rename ap_casecmpstr[n]() to ap_cstr_casecmp[n](), update with APR doxygen
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1747469 13f79535-47bb-0310-9956-ffa450edef68
2016-06-09 00:06:42 +00:00
Jim Jagielski
69b41bc90b Some flow improvements...
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1737020 13f79535-47bb-0310-9956-ffa450edef68
2016-03-29 16:47:05 +00:00
Jim Jagielski
5a902d26e7 protect logic in case backend == NULL
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1736563 13f79535-47bb-0310-9956-ffa450edef68
2016-03-25 12:14:30 +00:00
Yann Ylavic
5934ef2936 mod_proxy_hcheck: add missing APLOGNO()s.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1732957 13f79535-47bb-0310-9956-ffa450edef68
2016-02-29 22:00:09 +00:00
Yann Ylavic
36f8375ec2 Avoid compiler (gcc-5.3.1) warning on unused variable.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1732953 13f79535-47bb-0310-9956-ffa450edef68
2016-02-29 21:45:24 +00:00
Jim Jagielski
8350ace9c7 remove as requested by yann
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1729429 13f79535-47bb-0310-9956-ffa450edef68
2016-02-09 17:50:02 +00:00
Christophe Jaillet
7c55823868 Remove now useless cast.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1728744 13f79535-47bb-0310-9956-ffa450edef68
2016-02-05 22:21:40 +00:00
Jim Jagielski
5f5e5bde8b Enabling a worker via health-check also moves them out of
ERROR more (which may have been set via the static
"health" check done via mod_proxy).

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1728326 13f79535-47bb-0310-9956-ffa450edef68
2016-02-03 14:33:43 +00:00
Jim Jagielski
8b3107f64c Only health-check workers which are not STOPPED
Only log Checking if we are actually checking

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1728325 13f79535-47bb-0310-9956-ffa450edef68
2016-02-03 14:30:53 +00:00
Jim Jagielski
ddc56a597b Now honor changed params!
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1728203 13f79535-47bb-0310-9956-ffa450edef68
2016-02-02 20:28:13 +00:00
Jim Jagielski
3d4399435e Now input-ize the values... next step is to tie into the
actual POST

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1728166 13f79535-47bb-0310-9956-ffa450edef68
2016-02-02 18:04:46 +00:00
Jim Jagielski
ee6d08cab1 Tie bal-man to hcheck for dynamic adjustments... right now,
actually editing not implemented yet.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1728161 13f79535-47bb-0310-9956-ffa450edef68
2016-02-02 17:23:43 +00:00
Jim Jagielski
62a5f9e552 Since these are externs, prepend proxy_
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1728148 13f79535-47bb-0310-9956-ffa450edef68
2016-02-02 15:21:38 +00:00