mod_proxy.h revision 41727a53c70d500138e14af00afc3d49455ecced
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding/* Licensed to the Apache Software Foundation (ASF) under one or more
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * contributor license agreements. See the NOTICE file distributed with
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * this work for additional information regarding copyright ownership.
b99dbaab171d91e1b664397cc40e039d0c087c65fielding * The ASF licenses this file to You under the Apache License, Version 2.0
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * (the "License"); you may not use this file except in compliance with
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * the License. You may obtain a copy of the License at
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * Unless required by applicable law or agreed to in writing, software
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * distributed under the License is distributed on an "AS IS" BASIS,
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * See the License for the specific language governing permissions and
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * limitations under the License.
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * @brief Proxy Extension Module for Apache
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding * @defgroup MOD_PROXY mod_proxy
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * @ingroup APACHE_MODS
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding Also note numerous FIXMEs and CHECKMEs which should be eliminated.
64185f9824e42f21ca7b9ae6c004484215c031a7rbb This code is once again experimental!
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding Things to do:
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding 1. Make it completely work (for FTP too)
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding 2. HTTP/1.1
ab2c1c1c83ec91415565da5a71fbc15d9685caa6fielding Chuck Murcko <chuck@topsail.org> 02-06-01
3568de757bac0b47256647504c186d17ca272f85rbb/* for proxy_canonenc() */
3568de757bac0b47256647504c186d17ca272f85rbb#else /*APR_CHARSET_EBCDIC*/
3568de757bac0b47256647504c186d17ca272f85rbb#endif /*APR_CHARSET_EBCDIC*/
3568de757bac0b47256647504c186d17ca272f85rbb/* default Max-Forwards header setting */
3568de757bac0b47256647504c186d17ca272f85rbb/* static information about a remote proxy */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding const char *scheme; /* the schemes handled by this proxy, or '*' */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding const char *protocol; /* the scheme used to talk to this proxy */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding const char *hostname; /* the hostname of this proxy */
3568de757bac0b47256647504c186d17ca272f85rbb ap_regex_t *regexp; /* compiled regex (if any) for the remote */
3568de757bac0b47256647504c186d17ca272f85rbb int use_regex; /* simple boolean. True if we have a regex pattern */
db12cd62083041bf90945eeb90cc40fbd2340797trawick const char *real;
db12cd62083041bf90945eeb90cc40fbd2340797trawick const char *fake;
3568de757bac0b47256647504c186d17ca272f85rbb int (*matcher) (struct dirconn_entry * This, request_rec *r);
3568de757bac0b47256647504c186d17ca272f85rbb const char *name;
3568de757bac0b47256647504c186d17ca272f85rbbtypedef struct proxy_balancer_method proxy_balancer_method;
3568de757bac0b47256647504c186d17ca272f85rbbtypedef struct {
3568de757bac0b47256647504c186d17ca272f85rbb proxy_worker *reverse; /* reverse "module-driven" proxy worker */
3568de757bac0b47256647504c186d17ca272f85rbb const char *domain; /* domain name to use in absence of a domain name in the request */
3568de757bac0b47256647504c186d17ca272f85rbb * the following setting masks the error page
3568de757bac0b47256647504c186d17ca272f85rbb * returned from the 'proxied server' and just
3568de757bac0b47256647504c186d17ca272f85rbb * forwards the status code upwards.
3568de757bac0b47256647504c186d17ca272f85rbb * This allows the main server (us) to generate
41634f717c623556a16b27b25d7d909a66fe20f8wrowe * the error page, (so it will look like a error
3568de757bac0b47256647504c186d17ca272f85rbb * returned from the rest of the system
3568de757bac0b47256647504c186d17ca272f85rbb/* putting new stuff on the end maximises binary back-compatibility.
3568de757bac0b47256647504c186d17ca272f85rbb * the strmatch_patterns are really a const just to have a
3568de757bac0b47256647504c186d17ca272f85rbb * case-independent strstr.
0375f54d32af9c27de0006956d9f85d01b020351stoddard apr_pool_t *pool; /* Pool used for allocating this struct */
3568de757bac0b47256647504c186d17ca272f85rbbtypedef struct {
24b534291150023e6b68eca89ddd33e475ccddc0wrowe const char *p; /* The path */
24b534291150023e6b68eca89ddd33e475ccddc0wrowe int p_is_fnmatch; /* Is this path an fnmatch candidate? */
3568de757bac0b47256647504c186d17ca272f85rbb/* ProxyPassReverse and friends are documented as working inside
fc1efab92032301e317f07e1b3a00082d9d71f3frbb * <Location>. But in fact they never have done in the case of
3568de757bac0b47256647504c186d17ca272f85rbb * more than one <Location>, because the server_conf can't see it.
fc1efab92032301e317f07e1b3a00082d9d71f3frbb * We need to move them to the per-dir config.
3568de757bac0b47256647504c186d17ca272f85rbb * Discussed in February:
fc1efab92032301e317f07e1b3a00082d9d71f3frbb * http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=110726027118798&w=2
3568de757bac0b47256647504c186d17ca272f85rbb/* if we interpolate env vars per-request, we'll need a per-request
3568de757bac0b47256647504c186d17ca272f85rbb * copy of the reverse proxy config
3568de757bac0b47256647504c186d17ca272f85rbbtypedef struct {
3568de757bac0b47256647504c186d17ca272f85rbbtypedef struct {
3568de757bac0b47256647504c186d17ca272f85rbb const char *hostname;
3568de757bac0b47256647504c186d17ca272f85rbb apr_pool_t *pool; /* Subpool used for creating socket */
3568de757bac0b47256647504c186d17ca272f85rbb apr_sockaddr_t *addr; /* Preparsed remote address info */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding proxy_worker *worker; /* Connection pool this connection belogns to */
3568de757bac0b47256647504c186d17ca272f85rbbtypedef struct {
ad83978f20c7d1a4323059d9af122e56fcd353bdstoddard/* Connection pool */
3568de757bac0b47256647504c186d17ca272f85rbb apr_pool_t *pool; /* The pool used in constructor and destructor calls */
3568de757bac0b47256647504c186d17ca272f85rbb apr_sockaddr_t *addr; /* Preparsed remote address info */
3568de757bac0b47256647504c186d17ca272f85rbb proxy_conn_rec *conn; /* Single connection for prefork mpm's */
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj/* worker status flags */
ca53a74f4012a45cbad48e940eddf27d866981f9dougm#define PROXY_WORKER_NOT_USABLE_BITMAP ( PROXY_WORKER_IN_SHUTDOWN | \
239f998fbee5ac5b114b965bb76e217cce0003edstoddardPROXY_WORKER_DISABLED | PROXY_WORKER_STOPPED | PROXY_WORKER_IN_ERROR )
3568de757bac0b47256647504c186d17ca272f85rbb#define PROXY_WORKER_IS_INITIALIZED(f) ( (f)->s->status & \
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding (PROXY_WORKER_NOT_USABLE_BITMAP)) && PROXY_WORKER_IS_INITIALIZED(f) )
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding/* default worker retry timeout in seconds */
3568de757bac0b47256647504c186d17ca272f85rbb/* Runtime worker status informations. Shared in scoreboard */
3568de757bac0b47256647504c186d17ca272f85rbbtypedef struct {
3568de757bac0b47256647504c186d17ca272f85rbb apr_off_t transferred;/* Number of bytes transferred to remote */
3568de757bac0b47256647504c186d17ca272f85rbb apr_size_t elected; /* Number of times the worker was elected */
3568de757bac0b47256647504c186d17ca272f85rbb/* Worker configuration */
3568de757bac0b47256647504c186d17ca272f85rbb const char *name;
3568de757bac0b47256647504c186d17ca272f85rbb const char *redirect; /* temporary balancing redirection route */
3568de757bac0b47256647504c186d17ca272f85rbb int min; /* Desired minimum number of available connections */
3568de757bac0b47256647504c186d17ca272f85rbb int smax; /* Soft maximum on the total number of connections */
3568de757bac0b47256647504c186d17ca272f85rbb int hmax; /* Hard maximum on the total number of connections */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding apr_interval_time_t ttl; /* maximum amount of time in seconds a connection
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding * may be available while exceeding the soft limit */
0f081398cf0eef8cc7c66a535d450110a92dc8aefielding apr_interval_time_t timeout; /* connection timeout */
3568de757bac0b47256647504c186d17ca272f85rbb apr_interval_time_t acquire; /* acquire timeout when the maximum number of connections is exceeded */
5a0f707b48da7703cbe6bc087f13a6735b1c742dgregames apr_thread_mutex_t *mutex; /* Thread lock for updating address cache */
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj int flush_wait; /* poll wait time in microseconds if flush_auto */
3568de757bac0b47256647504c186d17ca272f85rbb * Wait 10000 microseconds to find out if more data is currently
3568de757bac0b47256647504c186d17ca272f85rbb * available at the backend. Just an arbitrary choose.
3568de757bac0b47256647504c186d17ca272f85rbb apr_array_header_t *workers; /* array of proxy_workers */
42b95445a3e9b563e716503b91df6b433f9fb29agregames int sticky_force; /* Disable failover for sticky sessions */
3568de757bac0b47256647504c186d17ca272f85rbb apr_interval_time_t timeout; /* Timeout for waiting on free connection */
3568de757bac0b47256647504c186d17ca272f85rbb int max_attempts; /* Number of attempts before failing */
3568de757bac0b47256647504c186d17ca272f85rbb /* XXX: Perhaps we will need the proc mutex too.
3568de757bac0b47256647504c186d17ca272f85rbb * Altrough we are only using arithmetic operations
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * it may lead to a incorrect calculations.
3568de757bac0b47256647504c186d17ca272f85rbb * For now use only the thread mutex.
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe apr_thread_mutex_t *mutex; /* Thread lock for updating lb params */
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe const char *name; /* name of the load balancer method*/
3568de757bac0b47256647504c186d17ca272f85rbb#define PROXY_THREAD_LOCK(x) apr_thread_mutex_lock((x)->mutex)
3568de757bac0b47256647504c186d17ca272f85rbb#define PROXY_THREAD_UNLOCK(x) apr_thread_mutex_unlock((x)->mutex)
3568de757bac0b47256647504c186d17ca272f85rbb/* hooks */
3568de757bac0b47256647504c186d17ca272f85rbb/* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and
3568de757bac0b47256647504c186d17ca272f85rbb * PROXY_DECLARE_DATA with appropriate export and import tags for the platform
3568de757bac0b47256647504c186d17ca272f85rbb#if !defined(WIN32)
3568de757bac0b47256647504c186d17ca272f85rbb#define PROXY_DECLARE(type) __declspec(dllexport) type __stdcall
3568de757bac0b47256647504c186d17ca272f85rbb#define PROXY_DECLARE_NONSTD(type) __declspec(dllexport) type
3568de757bac0b47256647504c186d17ca272f85rbb#define PROXY_DECLARE(type) __declspec(dllimport) type __stdcall
3568de757bac0b47256647504c186d17ca272f85rbb#define PROXY_DECLARE_NONSTD(type) __declspec(dllimport) type
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * Hook an optional proxy hook. Unlike static hooks, this uses a macro
3568de757bac0b47256647504c186d17ca272f85rbb * instead of a function.
3568de757bac0b47256647504c186d17ca272f85rbbAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
3568de757bac0b47256647504c186d17ca272f85rbb proxy_worker *worker, proxy_server_conf *conf, char *url,
3568de757bac0b47256647504c186d17ca272f85rbbAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r,
3568de757bac0b47256647504c186d17ca272f85rbbAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr))
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wroweAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, fixups, (request_rec *r))
3568de757bac0b47256647504c186d17ca272f85rbb * pre request hook.
24b534291150023e6b68eca89ddd33e475ccddc0wrowe * It will return the most suitable worker at the moment
24b534291150023e6b68eca89ddd33e475ccddc0wrowe * and coresponding balancer.
3568de757bac0b47256647504c186d17ca272f85rbb * The url is rewritten from balancer://cluster/uri to scheme://host:port/uri
3568de757bac0b47256647504c186d17ca272f85rbb * and then the scheme_handler is called.
24b534291150023e6b68eca89ddd33e475ccddc0wroweAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, pre_request, (proxy_worker **worker,
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * post request hook.
3568de757bac0b47256647504c186d17ca272f85rbb * It is called after request for updating runtime balancer status.
3568de757bac0b47256647504c186d17ca272f85rbbAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, post_request, (proxy_worker *worker,
5a0f707b48da7703cbe6bc087f13a6735b1c742dgregames * request status hook
3568de757bac0b47256647504c186d17ca272f85rbb * It is called after all proxy processing has been done. This gives other
3568de757bac0b47256647504c186d17ca272f85rbb * modules a chance to create default content on failure, for example
3568de757bac0b47256647504c186d17ca272f85rbbAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, request_status,
3568de757bac0b47256647504c186d17ca272f85rbbPROXY_DECLARE(request_rec *)ap_proxy_make_fake_req(conn_rec *c, request_rec *r);
3568de757bac0b47256647504c186d17ca272f85rbbPROXY_DECLARE(char *)ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t,
3568de757bac0b47256647504c186d17ca272f85rbbPROXY_DECLARE(char *)ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp,
fe6baec9bbcd36f932b71a355120cd7b5a685d6cfieldingPROXY_DECLARE(const char *)ap_proxy_date_canon(apr_pool_t *p, const char *x);
3568de757bac0b47256647504c186d17ca272f85rbbPROXY_DECLARE(int) ap_proxy_liststr(const char *list, const char *val);
3568de757bac0b47256647504c186d17ca272f85rbbPROXY_DECLARE(char *)ap_proxy_removestr(apr_pool_t *pool, const char *list, const char *val);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(int) ap_proxyerror(request_rec *r, int statuscode, const char *message);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(int) ap_proxy_is_ipaddr(struct dirconn_entry *This, apr_pool_t *p);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(int) ap_proxy_is_domainname(struct dirconn_entry *This, apr_pool_t *p);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(int) ap_proxy_is_hostname(struct dirconn_entry *This, apr_pool_t *p);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(int) ap_proxy_is_word(struct dirconn_entry *This, apr_pool_t *p);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(int) ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf, apr_sockaddr_t *uri_addr);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(int) ap_proxy_pre_http_request(conn_rec *c, request_rec *r);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(apr_status_t) ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb, char *buff, size_t bufflen, int *eos);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(void) ap_proxy_table_unmerge(apr_pool_t *p, apr_table_t *t, char *key);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe/* DEPRECATED (will be replaced with ap_proxy_connect_backend */
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **, const char *, apr_sockaddr_t *, const char *, proxy_server_conf *, server_rec *, apr_pool_t *);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(int) ap_proxy_conn_is_https(conn_rec *c);
3568de757bac0b47256647504c186d17ca272f85rbbPROXY_DECLARE(const char *) ap_proxy_ssl_val(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r, const char *var);
8e9734d1a4af74c141e2a0f880bb51bb061fa03atrawick/* Header mapping functions, and a typedef of their signature */
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *url);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(const char *) ap_proxy_cookie_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *str);
8e9734d1a4af74c141e2a0f880bb51bb061fa03atrawick#if !defined(WIN32)
3568de757bac0b47256647504c186d17ca272f85rbbtypedef const char *(*ap_proxy_header_reverse_map_fn)(request_rec *,
3568de757bac0b47256647504c186d17ca272f85rbb proxy_dir_conf *, const char *);
0f113d7123e8bd3e3e2e9b6373461a1a773bfccatrawicktypedef const char *(__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
0f113d7123e8bd3e3e2e9b6373461a1a773bfccatrawick proxy_dir_conf *, const char *);
3568de757bac0b47256647504c186d17ca272f85rbb (__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
8e9734d1a4af74c141e2a0f880bb51bb061fa03atrawick proxy_dir_conf *, const char *);
3568de757bac0b47256647504c186d17ca272f85rbb (__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
3568de757bac0b47256647504c186d17ca272f85rbb proxy_dir_conf *, const char *);
3568de757bac0b47256647504c186d17ca272f85rbb/* Connection pool API */
3568de757bac0b47256647504c186d17ca272f85rbb * Get the worker from proxy configuration
3568de757bac0b47256647504c186d17ca272f85rbb * @param p memory pool used for finding worker
3568de757bac0b47256647504c186d17ca272f85rbb * @param conf current proxy server configuration
3568de757bac0b47256647504c186d17ca272f85rbb * @param url url to find the worker from
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * @return proxy_worker or NULL if not found
ad83978f20c7d1a4323059d9af122e56fcd353bdstoddardPROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe const char *url);
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * Add the worker to proxy configuration
3568de757bac0b47256647504c186d17ca272f85rbb * @param worker the new worker
3568de757bac0b47256647504c186d17ca272f85rbb * @param p memory pool to allocate worker from
3568de757bac0b47256647504c186d17ca272f85rbb * @param conf current proxy server configuration
3568de757bac0b47256647504c186d17ca272f85rbb * @param url url containing worker name
3568de757bac0b47256647504c186d17ca272f85rbb * @return error message or NULL if successfull
3568de757bac0b47256647504c186d17ca272f85rbbPROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker,
3568de757bac0b47256647504c186d17ca272f85rbb const char *url);
3568de757bac0b47256647504c186d17ca272f85rbb * Create new worker
ad83978f20c7d1a4323059d9af122e56fcd353bdstoddard * @param p memory pool to allocate worker from
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * @return new worker
3568de757bac0b47256647504c186d17ca272f85rbbPROXY_DECLARE(proxy_worker *) ap_proxy_create_worker(apr_pool_t *p);
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * Initize the worker's shared data
3568de757bac0b47256647504c186d17ca272f85rbb * @param conf current proxy server configuration
3568de757bac0b47256647504c186d17ca272f85rbb * @param worker worker to initialize
ad83978f20c7d1a4323059d9af122e56fcd353bdstoddard * @param s current server record
3568de757bac0b47256647504c186d17ca272f85rbb * @param worker worker to initialize
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpjPROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf,
3568de757bac0b47256647504c186d17ca272f85rbb * Initize the worker
3568de757bac0b47256647504c186d17ca272f85rbb * @param worker worker to initialize
3568de757bac0b47256647504c186d17ca272f85rbb * @param s current server record
3568de757bac0b47256647504c186d17ca272f85rbb * @return APR_SUCCESS or error code
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpjPROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker,
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * Get the balancer from proxy configuration
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * @param p memory pool used for finding balancer
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * @param conf current proxy server configuration
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * @param url url to find the worker from. Has to have balancer:// prefix
3568de757bac0b47256647504c186d17ca272f85rbb * @return proxy_balancer or NULL if not found
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpjPROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
3568de757bac0b47256647504c186d17ca272f85rbb const char *url);
3568de757bac0b47256647504c186d17ca272f85rbb * Add the balancer to proxy configuration
3568de757bac0b47256647504c186d17ca272f85rbb * @param balancer the new balancer
3568de757bac0b47256647504c186d17ca272f85rbb * @param p memory pool to allocate balancer from
0f113d7123e8bd3e3e2e9b6373461a1a773bfccatrawick * @param conf current proxy server configuration
0f113d7123e8bd3e3e2e9b6373461a1a773bfccatrawick * @param url url containing balancer name
3568de757bac0b47256647504c186d17ca272f85rbb * @return error message or NULL if successfull
3568de757bac0b47256647504c186d17ca272f85rbbPROXY_DECLARE(const char *) ap_proxy_add_balancer(proxy_balancer **balancer,
3568de757bac0b47256647504c186d17ca272f85rbb const char *url);
3568de757bac0b47256647504c186d17ca272f85rbb * Add the worker to the balancer
3568de757bac0b47256647504c186d17ca272f85rbb * @param pool memory pool for adding worker
3568de757bac0b47256647504c186d17ca272f85rbb * @param balancer balancer to add to
3568de757bac0b47256647504c186d17ca272f85rbb * @param balancer worker to add
3568de757bac0b47256647504c186d17ca272f85rbb * @note Single worker can be added to multiple balancers.
3568de757bac0b47256647504c186d17ca272f85rbbPROXY_DECLARE(void) ap_proxy_add_worker_to_balancer(apr_pool_t *pool,
3568de757bac0b47256647504c186d17ca272f85rbb * Get the most suitable worker and(or) balancer for the request
3568de757bac0b47256647504c186d17ca272f85rbb * @param worker worker used for processing request
3568de757bac0b47256647504c186d17ca272f85rbb * @param balancer balancer used for processing request
3568de757bac0b47256647504c186d17ca272f85rbb * @param r current request
3568de757bac0b47256647504c186d17ca272f85rbb * @param conf current proxy server configuration
3568de757bac0b47256647504c186d17ca272f85rbb * @param url request url that balancer can rewrite.
3568de757bac0b47256647504c186d17ca272f85rbb * @return OK or HTTP_XXX error
3568de757bac0b47256647504c186d17ca272f85rbb * @note It calls balancer pre_request hook if the url starts with balancer://
ec020ca384efb30d501a5af796ddc3bb237d7b8fgregames * The balancer then rewrites the url to particular worker, like http://host:port
ec020ca384efb30d501a5af796ddc3bb237d7b8fgregamesPROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
3568de757bac0b47256647504c186d17ca272f85rbb * Post request worker and balancer cleanup
5f4e89b7e376d596fbf5167314a3781fd0889064trawick * @param worker worker used for processing request
5f4e89b7e376d596fbf5167314a3781fd0889064trawick * @param balancer balancer used for processing request
5f4e89b7e376d596fbf5167314a3781fd0889064trawick * @param r current request
3568de757bac0b47256647504c186d17ca272f85rbb * @param conf current proxy server configuration
3568de757bac0b47256647504c186d17ca272f85rbb * @return OK or HTTP_XXX error
3568de757bac0b47256647504c186d17ca272f85rbb * @note When ever the pre_request is called, the post_request has to be
3568de757bac0b47256647504c186d17ca272f85rbb * called too.
3568de757bac0b47256647504c186d17ca272f85rbbPROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker,
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * Request status function
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * @param status status of proxy request
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * @return OK or DECLINED
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj PROXY_DECLARE(int) ap_proxy_request_status(int *status, request_rec *r);
3568de757bac0b47256647504c186d17ca272f85rbb * Deternime backend hostname and port
3568de757bac0b47256647504c186d17ca272f85rbb * @param p memory pool used for processing
3568de757bac0b47256647504c186d17ca272f85rbb * @param r current request
3568de757bac0b47256647504c186d17ca272f85rbb * @param conf current proxy server configuration
3568de757bac0b47256647504c186d17ca272f85rbb * @param worker worker used for processing request
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * @param conn proxy connection struct
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * @param uri processed uri
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * @param url request url
3568de757bac0b47256647504c186d17ca272f85rbb * @param proxyname are we connecting directly or via s proxy
3568de757bac0b47256647504c186d17ca272f85rbb * @param proxyport proxy host port
3568de757bac0b47256647504c186d17ca272f85rbb * @param server_portstr Via headers server port
3568de757bac0b47256647504c186d17ca272f85rbb * @param server_portstr_size size of the server_portstr buffer
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * @return OK or HTTP_XXX error
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(int) ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe const char *proxyname,
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * Mark a worker for retry
3568de757bac0b47256647504c186d17ca272f85rbb * @param proxy_function calling proxy scheme (http, ajp, ...)
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * @param conf current proxy server configuration
3568de757bac0b47256647504c186d17ca272f85rbb * @param worker worker used for retrying
3568de757bac0b47256647504c186d17ca272f85rbb * @param s current server record
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * @return OK if marked for retry, DECLINED otherwise
3568de757bac0b47256647504c186d17ca272f85rbb * @note Worker will be marker for retry if the time of the last retry
3568de757bac0b47256647504c186d17ca272f85rbb * has been ellapsed. In case there is no retry option set, defaults to
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * number_of_retries seconds.
3568de757bac0b47256647504c186d17ca272f85rbbPROXY_DECLARE(int) ap_proxy_retry_worker(const char *proxy_function,
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * Acquire a connection from workers connection pool
3568de757bac0b47256647504c186d17ca272f85rbb * @param proxy_function calling proxy scheme (http, ajp, ...)
3568de757bac0b47256647504c186d17ca272f85rbb * @param conn acquired connection
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * @param worker worker used for obtaining connection
3568de757bac0b47256647504c186d17ca272f85rbb * @param s current server record
3568de757bac0b47256647504c186d17ca272f85rbb * @return OK or HTTP_XXX error
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * @note If the number of connections is exhaused the function will
3568de757bac0b47256647504c186d17ca272f85rbb * block untill the timeout is reached.
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(int) ap_proxy_acquire_connection(const char *proxy_function,
3568de757bac0b47256647504c186d17ca272f85rbb * Release a connection back to worker connection pool
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * @param proxy_function calling proxy scheme (http, ajp, ...)
3568de757bac0b47256647504c186d17ca272f85rbb * @param conn acquired connection
5f4e89b7e376d596fbf5167314a3781fd0889064trawick * @param s current server record
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * @return OK or HTTP_XXX error
5f4e89b7e376d596fbf5167314a3781fd0889064trawick * @note The connection will be closed if conn->close_on_release is set
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowePROXY_DECLARE(int) ap_proxy_release_connection(const char *proxy_function,
3568de757bac0b47256647504c186d17ca272f85rbb * Make a connection to the backend
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * @param proxy_function calling proxy scheme (http, ajp, ...)
3568de757bac0b47256647504c186d17ca272f85rbb * @param conn acquired connection
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * @param worker connection worker
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * @param s current server record
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * @return OK or HTTP_XXX error
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * @note In case the socket already exists for conn, just check the link
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpjPROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
aa616c3b5a4aa59867472cddf7d8e63693808f0erederpj * Make a connection record for backend connection
3568de757bac0b47256647504c186d17ca272f85rbb * @param proxy_function calling proxy scheme (http, ajp, ...)
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * @param conn acquired connection
3568de757bac0b47256647504c186d17ca272f85rbb * @param c client connection record
3568de757bac0b47256647504c186d17ca272f85rbb * @param s current server record
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * @return OK or HTTP_XXX error
3568de757bac0b47256647504c186d17ca272f85rbbPROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,
3568de757bac0b47256647504c186d17ca272f85rbb * Signal the upstream chain that the connection to the backend broke in the
3568de757bac0b47256647504c186d17ca272f85rbb * middle of the response. This is done by sending an error bucket with
3568de757bac0b47256647504c186d17ca272f85rbb * status HTTP_BAD_GATEWAY and an EOS bucket up the filter chain.
3568de757bac0b47256647504c186d17ca272f85rbb * @param r current request record of client request
3568de757bac0b47256647504c186d17ca272f85rbb * @param brigade The brigade that is sent through the output filter chain
ad83978f20c7d1a4323059d9af122e56fcd353bdstoddardPROXY_DECLARE(void) ap_proxy_backend_broke(request_rec *r,
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe/* The number of dynamic workers that can be added when reconfiguring.
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * If this limit is reached you must stop and restart the server.
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * Calculate number of maximum number of workers in scoreboard.
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe * @return number of workers to allocate in the scoreboard
3568de757bac0b47256647504c186d17ca272f85rbb/* For proxy_util */
1ec8bd0373f11c07688ec9afbbf778cf78a0bc52wrowe#endif /*MOD_PROXY_H*/