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