mod_proxy.h revision 6fb984bb49f217c3b76cdbe864f105d2e74e52ed
2d2eda71267231c2526be701fe655db125852c1ffielding/* Licensed to the Apache Software Foundation (ASF) under one or more
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * contributor license agreements. See the NOTICE file distributed with
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * this work for additional information regarding copyright ownership.
b99dbaab171d91e1b664397cc40e039d0c087c65fielding * The ASF licenses this file to You under the Apache License, Version 2.0
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * (the "License"); you may not use this file except in compliance with
2d2eda71267231c2526be701fe655db125852c1ffielding * the License. You may obtain a copy of the License at
2d2eda71267231c2526be701fe655db125852c1ffielding *
2d2eda71267231c2526be701fe655db125852c1ffielding * http://www.apache.org/licenses/LICENSE-2.0
2d2eda71267231c2526be701fe655db125852c1ffielding *
2d2eda71267231c2526be701fe655db125852c1ffielding * Unless required by applicable law or agreed to in writing, software
2d2eda71267231c2526be701fe655db125852c1ffielding * distributed under the License is distributed on an "AS IS" BASIS,
2d2eda71267231c2526be701fe655db125852c1ffielding * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2d2eda71267231c2526be701fe655db125852c1ffielding * See the License for the specific language governing permissions and
2d2eda71267231c2526be701fe655db125852c1ffielding * limitations under the License.
2d2eda71267231c2526be701fe655db125852c1ffielding */
2d2eda71267231c2526be701fe655db125852c1ffielding
2d2eda71267231c2526be701fe655db125852c1ffielding#ifndef MOD_PROXY_H
2d2eda71267231c2526be701fe655db125852c1ffielding#define MOD_PROXY_H
f062ed7bd262a37a909dd77ce5fc23b446818823fielding
f062ed7bd262a37a909dd77ce5fc23b446818823fielding/**
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * @file mod_proxy.h
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * @brief Proxy Extension Module for Apache
f062ed7bd262a37a909dd77ce5fc23b446818823fielding *
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * @defgroup MOD_PROXY mod_proxy
2d2eda71267231c2526be701fe655db125852c1ffielding * @ingroup APACHE_MODS
f062ed7bd262a37a909dd77ce5fc23b446818823fielding * @{
f062ed7bd262a37a909dd77ce5fc23b446818823fielding */
f062ed7bd262a37a909dd77ce5fc23b446818823fielding
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "apr_hooks.h"
2d2eda71267231c2526be701fe655db125852c1ffielding#include "apr_optional.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "apr.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "apr_lib.h"
64185f9824e42f21ca7b9ae6c004484215c031a7rbb#include "apr_strings.h"
2d2eda71267231c2526be701fe655db125852c1ffielding#include "apr_buckets.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "apr_md5.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "apr_network_io.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "apr_pools.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "apr_strings.h"
2d2eda71267231c2526be701fe655db125852c1ffielding#include "apr_uri.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "apr_date.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "apr_strmatch.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "apr_fnmatch.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "apr_reslist.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#define APR_WANT_STRFUNC
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "apr_want.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "apr_uuid.h"
2d2eda71267231c2526be701fe655db125852c1ffielding#include "util_mutex.h"
2d2eda71267231c2526be701fe655db125852c1ffielding#include "apr_global_mutex.h"
2d2eda71267231c2526be701fe655db125852c1ffielding#include "apr_thread_mutex.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "httpd.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "http_config.h"
2d2eda71267231c2526be701fe655db125852c1ffielding#include "ap_config.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "http_core.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "http_protocol.h"
f062ed7bd262a37a909dd77ce5fc23b446818823fielding#include "http_request.h"
2d2eda71267231c2526be701fe655db125852c1ffielding#include "http_vhost.h"
2d2eda71267231c2526be701fe655db125852c1ffielding#include "http_main.h"
2d2eda71267231c2526be701fe655db125852c1ffielding#include "http_log.h"
2d2eda71267231c2526be701fe655db125852c1ffielding#include "http_connection.h"
2d2eda71267231c2526be701fe655db125852c1ffielding#include "util_filter.h"
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb#include "util_ebcdic.h"
b980ad7fdc218b4855cde9f75a747527f50c554dwrowe#include "ap_provider.h"
ab5581cc78e9d865b0a6ab1404c53347b3276968rbb#include "ap_slotmem.h"
92f3af936ce61f25358a3ee4f28df2f6d62040dfdreid
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb#if APR_HAVE_NETINET_IN_H
c9a95767fbf0f5fb0976a06b97a256033925e433rbb#include <netinet/in.h>
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding#endif
2d2eda71267231c2526be701fe655db125852c1ffielding#if APR_HAVE_ARPA_INET_H
2d2eda71267231c2526be701fe655db125852c1ffielding#include <arpa/inet.h>
2d2eda71267231c2526be701fe655db125852c1ffielding#endif
2d2eda71267231c2526be701fe655db125852c1ffielding
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* for proxy_canonenc() */
61fd0cab072a05b855cbef9c585702401ac5ae29rbbenum enctype {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb enc_path, enc_search, enc_user, enc_fpath, enc_parm
61fd0cab072a05b855cbef9c585702401ac5ae29rbb};
2d2eda71267231c2526be701fe655db125852c1ffielding
2d2eda71267231c2526be701fe655db125852c1ffielding#define BALANCER_PREFIX "balancer://"
2d2eda71267231c2526be701fe655db125852c1ffielding
2d2eda71267231c2526be701fe655db125852c1ffielding#if APR_CHARSET_EBCDIC
2d2eda71267231c2526be701fe655db125852c1ffielding#define CRLF "\r\n"
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#else /*APR_CHARSET_EBCDIC*/
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define CRLF "\015\012"
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#endif /*APR_CHARSET_EBCDIC*/
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* default Max-Forwards header setting */
2d2eda71267231c2526be701fe655db125852c1ffielding/* Set this to -1, which complies with RFC2616 by not setting
2d2eda71267231c2526be701fe655db125852c1ffielding * max-forwards if the client didn't send it to us.
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb */
bfb62a96023822c56c9120e4ee627d4091cc59c2rbb#define DEFAULT_MAX_FORWARDS -1
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbbtypedef struct proxy_balancer proxy_balancer;
61fd0cab072a05b855cbef9c585702401ac5ae29rbbtypedef struct proxy_worker proxy_worker;
61fd0cab072a05b855cbef9c585702401ac5ae29rbbtypedef struct proxy_conn_pool proxy_conn_pool;
61fd0cab072a05b855cbef9c585702401ac5ae29rbbtypedef struct proxy_balancer_method proxy_balancer_method;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
3d96ee83babeec32482c9082c9426340cee8c44dwrowe/* static information about a remote proxy */
2d2eda71267231c2526be701fe655db125852c1ffieldingstruct proxy_remote {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb const char *scheme; /* the schemes handled by this proxy, or '*' */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb const char *protocol; /* the scheme used to talk to this proxy */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb const char *hostname; /* the hostname of this proxy */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb ap_regex_t *regexp; /* compiled regex (if any) for the remote */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb int use_regex; /* simple boolean. True if we have a regex pattern */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_port_t port; /* the port for this proxy */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb};
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXYPASS_NOCANON 0x01
2d2eda71267231c2526be701fe655db125852c1ffielding#define PROXYPASS_INTERPOLATE 0x02
3d96ee83babeec32482c9082c9426340cee8c44dwrowe#define PROXYPASS_NOQUERY 0x04
2d2eda71267231c2526be701fe655db125852c1ffieldingstruct proxy_alias {
2d2eda71267231c2526be701fe655db125852c1ffielding const char *real;
2d2eda71267231c2526be701fe655db125852c1ffielding const char *fake;
2d2eda71267231c2526be701fe655db125852c1ffielding ap_regex_t *regex;
000b67449410515eac43e76ef6667915bfd4d2abgstein unsigned int flags;
2d2eda71267231c2526be701fe655db125852c1ffielding proxy_balancer *balancer; /* only valid for reverse-proxys */
2d2eda71267231c2526be701fe655db125852c1ffielding};
2d2eda71267231c2526be701fe655db125852c1ffielding
61fd0cab072a05b855cbef9c585702401ac5ae29rbbstruct dirconn_entry {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char *name;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb struct in_addr addr, mask;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb struct apr_sockaddr_t *hostaddr;
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein int (*matcher) (struct dirconn_entry * This, request_rec *r);
61fd0cab072a05b855cbef9c585702401ac5ae29rbb};
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein
7bdef86e15d47d16dcbe7a5611683191774bd5fbgsteinstruct noproxy_entry {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb const char *name;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb struct apr_sockaddr_t *addr;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb};
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbbtypedef struct {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_array_header_t *proxies;
3d96ee83babeec32482c9082c9426340cee8c44dwrowe apr_array_header_t *sec_proxy;
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein apr_array_header_t *aliases;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_array_header_t *noproxies;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_array_header_t *dirconn;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_array_header_t *workers; /* non-balancer workers, eg ProxyPass http://example.com */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_array_header_t *balancers; /* list of balancers @ config time */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb proxy_worker *forward; /* forward proxy worker */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb proxy_worker *reverse; /* reverse "module-driven" proxy worker */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb const char *domain; /* domain name to use in absence of a domain name in the request */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb const char *id;
3d96ee83babeec32482c9082c9426340cee8c44dwrowe apr_pool_t *pool; /* Pool used for allocating this struct */
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein int req; /* true if proxy requests are enabled */
c9a95767fbf0f5fb0976a06b97a256033925e433rbb int max_balancers; /* maximum number of allowed balancers */
c9a95767fbf0f5fb0976a06b97a256033925e433rbb int bgrowth; /* number of post-config balancers can added */
c9a95767fbf0f5fb0976a06b97a256033925e433rbb enum {
c9a95767fbf0f5fb0976a06b97a256033925e433rbb via_off,
c9a95767fbf0f5fb0976a06b97a256033925e433rbb via_on,
c9a95767fbf0f5fb0976a06b97a256033925e433rbb via_block,
c9a95767fbf0f5fb0976a06b97a256033925e433rbb via_full
c9a95767fbf0f5fb0976a06b97a256033925e433rbb } viaopt; /* how to deal with proxy Via: headers */
c9a95767fbf0f5fb0976a06b97a256033925e433rbb apr_size_t recv_buffer_size;
c9a95767fbf0f5fb0976a06b97a256033925e433rbb apr_size_t io_buffer_size;
c9a95767fbf0f5fb0976a06b97a256033925e433rbb long maxfwd;
c9a95767fbf0f5fb0976a06b97a256033925e433rbb apr_interval_time_t timeout;
c9a95767fbf0f5fb0976a06b97a256033925e433rbb enum {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb bad_error,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb bad_ignore,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb bad_body
61fd0cab072a05b855cbef9c585702401ac5ae29rbb } badopt; /* how to deal with bad headers */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb enum {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb status_off,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb status_on,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb status_full
61fd0cab072a05b855cbef9c585702401ac5ae29rbb } proxy_status; /* Status display options */
3d96ee83babeec32482c9082c9426340cee8c44dwrowe apr_sockaddr_t *source_address;
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein apr_global_mutex_t *mutex; /* global lock (needed??) */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb ap_slotmem_instance_t *bslot; /* balancers shm data - runtime */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb ap_slotmem_provider_t *storage;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int req_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int viaopt_set:1;
3d96ee83babeec32482c9082c9426340cee8c44dwrowe unsigned int recv_buffer_size_set:1;
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein unsigned int io_buffer_size_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int maxfwd_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int timeout_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int badopt_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int proxy_status_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int source_address_set:1;
3d96ee83babeec32482c9082c9426340cee8c44dwrowe unsigned int bgrowth_set:1;
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein unsigned int inherit:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int inherit_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int bal_persist:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb} proxy_server_conf;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbbtypedef struct {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb const char *p; /* The path */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb ap_regex_t *r; /* Is this a regex? */
3d96ee83babeec32482c9082c9426340cee8c44dwrowe
2d2eda71267231c2526be701fe655db125852c1ffielding/* FIXME
2d2eda71267231c2526be701fe655db125852c1ffielding * ProxyPassReverse and friends are documented as working inside
2d2eda71267231c2526be701fe655db125852c1ffielding * <Location>. But in fact they never have done in the case of
2d2eda71267231c2526be701fe655db125852c1ffielding * more than one <Location>, because the server_conf can't see it.
2d2eda71267231c2526be701fe655db125852c1ffielding * We need to move them to the per-dir config.
2d2eda71267231c2526be701fe655db125852c1ffielding * Discussed in February 2005:
2d2eda71267231c2526be701fe655db125852c1ffielding * http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=110726027118798&w=2
2d2eda71267231c2526be701fe655db125852c1ffielding */
2d2eda71267231c2526be701fe655db125852c1ffielding apr_array_header_t *raliases;
2d2eda71267231c2526be701fe655db125852c1ffielding apr_array_header_t* cookie_paths;
2d2eda71267231c2526be701fe655db125852c1ffielding apr_array_header_t* cookie_domains;
2d2eda71267231c2526be701fe655db125852c1ffielding signed char p_is_fnmatch; /* Is the path an fnmatch candidate? */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb signed char interpolate_env;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb struct proxy_alias *alias;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb /**
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * the following setting masks the error page
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * returned from the 'proxied server' and just
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * forwards the status code upwards.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * This allows the main server (us) to generate
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * the error page, (so it will look like a error
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * returned from the rest of the system
3d96ee83babeec32482c9082c9426340cee8c44dwrowe */
1ccd992d37d62c8cb2056126f2234f64ec189bfddougm unsigned int error_override:1;
7bdef86e15d47d16dcbe7a5611683191774bd5fbgstein unsigned int preserve_host:1;
23ff73a56371e21f16744cb94d06399b877829f1rbb unsigned int preserve_host_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int error_override_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int alias_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int add_forwarded_headers:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb} proxy_dir_conf;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* if we interpolate env vars per-request, we'll need a per-request
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * copy of the reverse proxy config
61fd0cab072a05b855cbef9c585702401ac5ae29rbb */
61fd0cab072a05b855cbef9c585702401ac5ae29rbbtypedef struct {
3d96ee83babeec32482c9082c9426340cee8c44dwrowe apr_array_header_t *raliases;
2d2eda71267231c2526be701fe655db125852c1ffielding apr_array_header_t* cookie_paths;
23ff73a56371e21f16744cb94d06399b877829f1rbb apr_array_header_t* cookie_domains;
2d2eda71267231c2526be701fe655db125852c1ffielding} proxy_req_conf;
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coartypedef struct {
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar conn_rec *connection;
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar request_rec *r; /* Request record of the backend request
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar * that is used over the backend connection. */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar proxy_worker *worker; /* Connection pool this connection belongs to */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar apr_pool_t *pool; /* Subpool for hostname and addr data */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar const char *hostname;
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar apr_sockaddr_t *addr; /* Preparsed remote address info */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar apr_pool_t *scpool; /* Subpool used for socket and connection data */
3d96ee83babeec32482c9082c9426340cee8c44dwrowe apr_socket_t *sock; /* Connection socket */
3d96ee83babeec32482c9082c9426340cee8c44dwrowe void *data; /* per scheme connection data */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar void *forward; /* opaque forward proxy data */
3d96ee83babeec32482c9082c9426340cee8c44dwrowe apr_uint32_t flags; /* Connection flags */
a19698aebe10b9d41574e4a73794ba7d4cecd78btrawick apr_port_t port;
a19698aebe10b9d41574e4a73794ba7d4cecd78btrawick unsigned int is_ssl:1;
a19698aebe10b9d41574e4a73794ba7d4cecd78btrawick unsigned int close:1; /* Close 'this' connection */
3d96ee83babeec32482c9082c9426340cee8c44dwrowe unsigned int need_flush:1; /* Flag to decide whether we need to flush the
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar * filter chain or not */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar unsigned int inreslist:1; /* connection in apr_reslist? */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar} proxy_conn_rec;
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coartypedef struct {
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar float cache_completion; /* completion percentage */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar int content_length; /* length of the content */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar} proxy_completion;
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar/* Connection pool */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coarstruct proxy_conn_pool {
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar apr_pool_t *pool; /* The pool used in constructor and destructor calls */
3d96ee83babeec32482c9082c9426340cee8c44dwrowe apr_sockaddr_t *addr; /* Preparsed remote address info */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar apr_reslist_t *res; /* Connection resource list */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar proxy_conn_rec *conn; /* Single connection for prefork mpm */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar};
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar/* Keep below in sync with proxy_util.c! */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar/* worker status bits */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_INITIALIZED 0x0001
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_IGNORE_ERRORS 0x0002
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_DRAIN 0x0004
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_IN_SHUTDOWN 0x0010
3d96ee83babeec32482c9082c9426340cee8c44dwrowe#define PROXY_WORKER_DISABLED 0x0020
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_STOPPED 0x0040
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_IN_ERROR 0x0080
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_HOT_STANDBY 0x0100
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_FREE 0x0200
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar/* worker status flags */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_INITIALIZED_FLAG 'O'
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_IGNORE_ERRORS_FLAG 'I'
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_DRAIN_FLAG 'N'
3d96ee83babeec32482c9082c9426340cee8c44dwrowe#define PROXY_WORKER_IN_SHUTDOWN_FLAG 'U'
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_DISABLED_FLAG 'D'
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_STOPPED_FLAG 'S'
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_IN_ERROR_FLAG 'E'
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_HOT_STANDBY_FLAG 'H'
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_FREE_FLAG 'F'
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_NOT_USABLE_BITMAP ( PROXY_WORKER_IN_SHUTDOWN | \
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coarPROXY_WORKER_DISABLED | PROXY_WORKER_STOPPED | PROXY_WORKER_IN_ERROR )
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar
3d96ee83babeec32482c9082c9426340cee8c44dwrowe/* NOTE: these check the shared status */
91f0d8da77152d24e4bbb31ce199282b3fd6e3b2coar#define PROXY_WORKER_IS_INITIALIZED(f) ( (f)->s->status & PROXY_WORKER_INITIALIZED )
2d2eda71267231c2526be701fe655db125852c1ffielding
2d2eda71267231c2526be701fe655db125852c1ffielding#define PROXY_WORKER_IS_STANDBY(f) ( (f)->s->status & PROXY_WORKER_HOT_STANDBY )
2d2eda71267231c2526be701fe655db125852c1ffielding
2d2eda71267231c2526be701fe655db125852c1ffielding#define PROXY_WORKER_IS_USABLE(f) ( ( !( (f)->s->status & PROXY_WORKER_NOT_USABLE_BITMAP) ) && \
61fd0cab072a05b855cbef9c585702401ac5ae29rbb PROXY_WORKER_IS_INITIALIZED(f) )
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_WORKER_IS_DRAINING(f) ( (f)->s->status & PROXY_WORKER_DRAIN )
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* default worker retry timeout in seconds */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_WORKER_DEFAULT_RETRY 60
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
3d96ee83babeec32482c9082c9426340cee8c44dwrowe/* Some max char string sizes, for shm fields */
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein#define PROXY_WORKER_MAX_SCHEME_SIZE 16
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_WORKER_MAX_ROUTE_SIZE 64
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_BALANCER_MAX_ROUTE_SIZE PROXY_WORKER_MAX_ROUTE_SIZE
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_WORKER_MAX_NAME_SIZE 96
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_BALANCER_MAX_NAME_SIZE PROXY_WORKER_MAX_NAME_SIZE
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_WORKER_MAX_HOSTNAME_SIZE 64
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_BALANCER_MAX_HOSTNAME_SIZE PROXY_WORKER_MAX_HOSTNAME_SIZE
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_BALANCER_MAX_STICKY_SIZE 64
3d96ee83babeec32482c9082c9426340cee8c44dwrowe
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein#define PROXY_MAX_PROVIDER_NAME_SIZE 16
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_STRNCPY(dst, src) ap_proxy_strncpy((dst), (src), (sizeof(dst)))
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_COPY_CONF_PARAMS(w, c) \
61fd0cab072a05b855cbef9c585702401ac5ae29rbbdo { \
61fd0cab072a05b855cbef9c585702401ac5ae29rbb(w)->s->timeout = (c)->timeout; \
61fd0cab072a05b855cbef9c585702401ac5ae29rbb(w)->s->timeout_set = (c)->timeout_set; \
61fd0cab072a05b855cbef9c585702401ac5ae29rbb(w)->s->recv_buffer_size = (c)->recv_buffer_size; \
3d96ee83babeec32482c9082c9426340cee8c44dwrowe(w)->s->recv_buffer_size_set = (c)->recv_buffer_size_set; \
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein(w)->s->io_buffer_size = (c)->io_buffer_size; \
61fd0cab072a05b855cbef9c585702401ac5ae29rbb(w)->s->io_buffer_size_set = (c)->io_buffer_size_set; \
61fd0cab072a05b855cbef9c585702401ac5ae29rbb} while (0)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* use 2 hashes */
61fd0cab072a05b855cbef9c585702401ac5ae29rbbtypedef struct {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int def;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int fnv;
3d96ee83babeec32482c9082c9426340cee8c44dwrowe} proxy_hashes ;
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* Runtime worker status informations. Shared in scoreboard */
61fd0cab072a05b855cbef9c585702401ac5ae29rbbtypedef struct {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char name[PROXY_WORKER_MAX_NAME_SIZE];
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char scheme[PROXY_WORKER_MAX_SCHEME_SIZE]; /* scheme to use ajp|http|https */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char hostname[PROXY_WORKER_MAX_HOSTNAME_SIZE]; /* remote backend address */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char route[PROXY_WORKER_MAX_ROUTE_SIZE]; /* balancing route */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char redirect[PROXY_WORKER_MAX_ROUTE_SIZE]; /* temporary balancing redirection route */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char flusher[PROXY_WORKER_MAX_SCHEME_SIZE]; /* flush provider used by mod_proxy_fdpass */
3d96ee83babeec32482c9082c9426340cee8c44dwrowe int lbset; /* load balancer cluster set */
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein int retries; /* number of retries on this worker */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb int lbstatus; /* Current lbstatus */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb int lbfactor; /* dynamic lbfactor */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb int min; /* Desired minimum number of available connections */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb int smax; /* Soft maximum on the total number of connections */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb int hmax; /* Hard maximum on the total number of connections */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb int flush_wait; /* poll wait time in microseconds if flush_auto */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb int index; /* shm array index */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb proxy_hashes hash; /* hash of worker name */
3d96ee83babeec32482c9082c9426340cee8c44dwrowe unsigned int status; /* worker status bitfield */
2d2eda71267231c2526be701fe655db125852c1ffielding enum {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb flush_off,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb flush_on,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb flush_auto
61fd0cab072a05b855cbef9c585702401ac5ae29rbb } flush_packets; /* control AJP flushing */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_time_t updated; /* timestamp of last update */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_time_t error_time; /* time of the last error */
3d96ee83babeec32482c9082c9426340cee8c44dwrowe apr_interval_time_t ttl; /* maximum amount of time in seconds a connection
2d2eda71267231c2526be701fe655db125852c1ffielding * may be available while exceeding the soft limit */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_interval_time_t retry; /* retry interval */
2d2eda71267231c2526be701fe655db125852c1ffielding apr_interval_time_t timeout; /* connection timeout */
2d2eda71267231c2526be701fe655db125852c1ffielding apr_interval_time_t acquire; /* acquire timeout when the maximum number of connections is exceeded */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_interval_time_t ping_timeout;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_interval_time_t conn_timeout;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_size_t recv_buffer_size;
2d2eda71267231c2526be701fe655db125852c1ffielding apr_size_t io_buffer_size;
3d96ee83babeec32482c9082c9426340cee8c44dwrowe apr_size_t elected; /* Number of times the worker was elected */
2d2eda71267231c2526be701fe655db125852c1ffielding apr_size_t busy; /* busyness factor */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_port_t port;
d839a9822ee53ce00da24c15f2d9fe054233d342gstein apr_off_t transferred;/* Number of bytes transferred to remote */
d839a9822ee53ce00da24c15f2d9fe054233d342gstein apr_off_t read; /* Number of bytes read from remote */
d839a9822ee53ce00da24c15f2d9fe054233d342gstein void *context; /* general purpose storage */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int keepalive:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int disablereuse:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int is_address_reusable:1;
d839a9822ee53ce00da24c15f2d9fe054233d342gstein unsigned int retry_set:1;
3d96ee83babeec32482c9082c9426340cee8c44dwrowe unsigned int timeout_set:1;
d839a9822ee53ce00da24c15f2d9fe054233d342gstein unsigned int acquire_set:1;
2d2eda71267231c2526be701fe655db125852c1ffielding unsigned int ping_timeout_set:1;
2d2eda71267231c2526be701fe655db125852c1ffielding unsigned int conn_timeout_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int recv_buffer_size_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int io_buffer_size_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int keepalive_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int disablereuse_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int was_malloced:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb} proxy_worker_shared;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define ALIGNED_PROXY_WORKER_SHARED_SIZE (APR_ALIGN_DEFAULT(sizeof(proxy_worker_shared)))
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* Worker configuration */
61fd0cab072a05b855cbef9c585702401ac5ae29rbbstruct proxy_worker {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb proxy_hashes hash; /* hash of worker name */
3d96ee83babeec32482c9082c9426340cee8c44dwrowe unsigned int local_status; /* status of per-process worker */
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein proxy_conn_pool *cp; /* Connection pool to use */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb proxy_worker_shared *s; /* Shared data */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb proxy_balancer *balancer; /* which balancer am I in? */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_thread_mutex_t *tmutex; /* Thread lock for updating address cache */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb void *context; /* general purpose storage */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb};
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/*
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * Time to wait (in microseconds) to find out if more data is currently
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * available at the backend.
3d96ee83babeec32482c9082c9426340cee8c44dwrowe */
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein#define PROXY_FLUSH_WAIT 10000
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbbtypedef struct {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char sticky_path[PROXY_BALANCER_MAX_STICKY_SIZE]; /* URL sticky session identifier */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char sticky[PROXY_BALANCER_MAX_STICKY_SIZE]; /* sticky session identifier */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char lbpname[PROXY_MAX_PROVIDER_NAME_SIZE]; /* lbmethod provider name */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char nonce[APR_UUID_FORMATTED_LENGTH + 1];
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char name[PROXY_BALANCER_MAX_NAME_SIZE];
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char sname[PROXY_BALANCER_MAX_NAME_SIZE];
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char vpath[PROXY_BALANCER_MAX_ROUTE_SIZE];
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char vhost[PROXY_BALANCER_MAX_HOSTNAME_SIZE];
3d96ee83babeec32482c9082c9426340cee8c44dwrowe apr_interval_time_t timeout; /* Timeout for waiting on free connection */
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein apr_time_t wupdated; /* timestamp of last change to workers list */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb int max_attempts; /* Number of attempts before failing */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb int index; /* shm array index */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb proxy_hashes hash;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int sticky_force:1; /* Disable failover for sticky sessions */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int scolonsep:1; /* true if ';' seps sticky session paths */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int max_attempts_set:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int was_malloced:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int need_reset:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int vhosted:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int inactive:1;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb unsigned int forcerecovery:1;
3d96ee83babeec32482c9082c9426340cee8c44dwrowe char sticky_separator; /* separator for sessionid/route */
2d2eda71267231c2526be701fe655db125852c1ffielding} proxy_balancer_shared;
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define ALIGNED_PROXY_BALANCER_SHARED_SIZE (APR_ALIGN_DEFAULT(sizeof(proxy_balancer_shared)))
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbbstruct proxy_balancer {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_array_header_t *workers; /* initially configured workers */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_array_header_t *errstatuses; /* statuses to force members into error */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb ap_slotmem_instance_t *wslot; /* worker shm data - runtime */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb ap_slotmem_provider_t *storage;
3d96ee83babeec32482c9082c9426340cee8c44dwrowe int growth; /* number of post-config workers can added */
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein int max_workers; /* maximum number of allowed workers */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb proxy_hashes hash;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_time_t wupdated; /* timestamp of last change to workers list */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb proxy_balancer_method *lbmethod;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_global_mutex_t *gmutex; /* global lock for updating list of workers */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_thread_mutex_t *tmutex; /* Thread lock for updating shm */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb proxy_server_conf *sconf;
61fd0cab072a05b855cbef9c585702401ac5ae29rbb void *context; /* general purpose storage */
3d96ee83babeec32482c9082c9426340cee8c44dwrowe proxy_balancer_shared *s; /* Shared data */
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein};
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbbstruct proxy_balancer_method {
61fd0cab072a05b855cbef9c585702401ac5ae29rbb const char *name; /* name of the load balancer method*/
61fd0cab072a05b855cbef9c585702401ac5ae29rbb proxy_worker *(*finder)(proxy_balancer *balancer,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb request_rec *r);
61fd0cab072a05b855cbef9c585702401ac5ae29rbb void *context; /* general purpose storage */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb apr_status_t (*reset)(proxy_balancer *balancer, server_rec *s);
3d96ee83babeec32482c9082c9426340cee8c44dwrowe apr_status_t (*age)(proxy_balancer *balancer, server_rec *s);
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein apr_status_t (*updatelbstatus)(proxy_balancer *balancer, proxy_worker *elected, server_rec *s);
61fd0cab072a05b855cbef9c585702401ac5ae29rbb};
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_THREAD_LOCK(x) ( (x) && (x)->tmutex ? apr_thread_mutex_lock((x)->tmutex) : APR_SUCCESS)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_THREAD_UNLOCK(x) ( (x) && (x)->tmutex ? apr_thread_mutex_unlock((x)->tmutex) : APR_SUCCESS)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_GLOBAL_LOCK(x) ( (x) && (x)->gmutex ? apr_global_mutex_lock((x)->gmutex) : APR_SUCCESS)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_GLOBAL_UNLOCK(x) ( (x) && (x)->gmutex ? apr_global_mutex_unlock((x)->gmutex) : APR_SUCCESS)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* hooks */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * PROXY_DECLARE_DATA with appropriate export and import tags for the platform
61fd0cab072a05b855cbef9c585702401ac5ae29rbb */
3d96ee83babeec32482c9082c9426340cee8c44dwrowe#if !defined(WIN32)
2d2eda71267231c2526be701fe655db125852c1ffielding#define PROXY_DECLARE(type) type
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_DECLARE_NONSTD(type) type
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_DECLARE_DATA
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#elif defined(PROXY_DECLARE_STATIC)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_DECLARE(type) type __stdcall
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_DECLARE_NONSTD(type) type
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_DECLARE_DATA
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#elif defined(PROXY_DECLARE_EXPORT)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_DECLARE(type) __declspec(dllexport) type __stdcall
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_DECLARE_NONSTD(type) __declspec(dllexport) type
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#define PROXY_DECLARE_DATA __declspec(dllexport)
61fd0cab072a05b855cbef9c585702401ac5ae29rbb#else
3d96ee83babeec32482c9082c9426340cee8c44dwrowe#define PROXY_DECLARE(type) __declspec(dllimport) type __stdcall
2d2eda71267231c2526be701fe655db125852c1ffielding#define PROXY_DECLARE_NONSTD(type) __declspec(dllimport) type
e351a4349a3dcc2e8d9c27bcdf72414bdde0942frbb#define PROXY_DECLARE_DATA __declspec(dllimport)
e351a4349a3dcc2e8d9c27bcdf72414bdde0942frbb#endif
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
2d2eda71267231c2526be701fe655db125852c1ffielding proxy_worker *worker, proxy_server_conf *conf, char *url,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb const char *proxyhost, apr_port_t proxyport))
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char *url))
2d2eda71267231c2526be701fe655db125852c1ffielding
3d96ee83babeec32482c9082c9426340cee8c44dwroweAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr))
2d2eda71267231c2526be701fe655db125852c1ffieldingAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, fixups, (request_rec *r))
344f3bc38dfccf6261d5bb8d689794cde113b3d6coar
344f3bc38dfccf6261d5bb8d689794cde113b3d6coar/**
344f3bc38dfccf6261d5bb8d689794cde113b3d6coar * pre request hook.
344f3bc38dfccf6261d5bb8d689794cde113b3d6coar * It will return the most suitable worker at the moment
344f3bc38dfccf6261d5bb8d689794cde113b3d6coar * and coresponding balancer.
344f3bc38dfccf6261d5bb8d689794cde113b3d6coar * The url is rewritten from balancer://cluster/uri to scheme://host:port/uri
344f3bc38dfccf6261d5bb8d689794cde113b3d6coar * and then the scheme_handler is called.
3d96ee83babeec32482c9082c9426340cee8c44dwrowe *
344f3bc38dfccf6261d5bb8d689794cde113b3d6coar */
d5df46b7972c0c4a5ca0ba5068e238f6053c2e6ftrawickAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, pre_request, (proxy_worker **worker,
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding proxy_balancer **balancer,
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding request_rec *r,
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding proxy_server_conf *conf, char **url))
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding/**
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding * post request hook.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * It is called after request for updating runtime balancer status.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb */
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, post_request, (proxy_worker *worker,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb proxy_balancer *balancer, request_rec *r,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb proxy_server_conf *conf))
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/**
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * request status hook
42ce672c516baf6e4eaed18ccc1647de2d456d8edougm * It is called after all proxy processing has been done. This gives other
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein * modules a chance to create default content on failure, for example
61fd0cab072a05b855cbef9c585702401ac5ae29rbb */
61fd0cab072a05b855cbef9c585702401ac5ae29rbbAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, request_status,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb (int *status, request_rec *r))
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbb/* proxy_util.c */
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
61fd0cab072a05b855cbef9c585702401ac5ae29rbbPROXY_DECLARE(apr_status_t) ap_proxy_strncpy(char *dst, const char *src,
42ce672c516baf6e4eaed18ccc1647de2d456d8edougm apr_size_t dlen);
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgsteinPROXY_DECLARE(int) ap_proxy_hex2c(const char *x);
61fd0cab072a05b855cbef9c585702401ac5ae29rbbPROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x);
61fd0cab072a05b855cbef9c585702401ac5ae29rbbPROXY_DECLARE(char *)ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb int forcedec, int proxyreq);
61fd0cab072a05b855cbef9c585702401ac5ae29rbbPROXY_DECLARE(char *)ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp,
61fd0cab072a05b855cbef9c585702401ac5ae29rbb char **passwordp, char **hostp, apr_port_t *port);
61fd0cab072a05b855cbef9c585702401ac5ae29rbbPROXY_DECLARE(int) ap_proxyerror(request_rec *r, int statuscode, const char *message);
61fd0cab072a05b855cbef9c585702401ac5ae29rbb
42ce672c516baf6e4eaed18ccc1647de2d456d8edougm/** Test whether the hostname/address of the request are blocked by the ProxyBlock
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein * configuration.
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * @param r request
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * @param conf server configuration
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * @param hostname hostname from request URI
61fd0cab072a05b855cbef9c585702401ac5ae29rbb * @param addr resolved address of hostname, or NULL if not known
dad234382d8424e1c5a30af2838e172aec9d6d1bdreid * @return OK on success, or else an errro
61fd0cab072a05b855cbef9c585702401ac5ae29rbb */
42ce672c516baf6e4eaed18ccc1647de2d456d8edougmPROXY_DECLARE(int) ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf,
fd0edaa8e3d4dd67d0604ccef2e96b071db96643fielding const char *hostname, apr_sockaddr_t *addr);
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb
a6b9ed64fdf548c61de9714e2cfb999ec59d149cgstein
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbbPROXY_DECLARE(int) ap_proxy_pre_http_request(conn_rec *c, request_rec *r);
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb/* DEPRECATED (will be replaced with ap_proxy_connect_backend */
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbbPROXY_DECLARE(int) ap_proxy_connect_to_backend(apr_socket_t **, const char *, apr_sockaddr_t *, const char *, proxy_server_conf *, request_rec *);
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbbPROXY_DECLARE(apr_status_t) ap_proxy_ssl_connection_cleanup(proxy_conn_rec *conn,
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb request_rec *r);
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbbPROXY_DECLARE(int) ap_proxy_ssl_enable(conn_rec *c);
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbbPROXY_DECLARE(int) ap_proxy_ssl_disable(conn_rec *c);
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbbPROXY_DECLARE(int) ap_proxy_conn_is_https(conn_rec *c);
8b7047e519340545e6807c9749576a40a76b6d3frbbPROXY_DECLARE(const char *) ap_proxy_ssl_val(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r, const char *var);
8b7047e519340545e6807c9749576a40a76b6d3frbb
8b7047e519340545e6807c9749576a40a76b6d3frbb/* Header mapping functions, and a typedef of their signature */
8b7047e519340545e6807c9749576a40a76b6d3frbbPROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *url);
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbbPROXY_DECLARE(const char *) ap_proxy_cookie_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *str);
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb
9484ae61c7cc5fa8d8d9a836efdbdb1e88d3036dwrowe#if !defined(WIN32)
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbbtypedef const char *(*ap_proxy_header_reverse_map_fn)(request_rec *,
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb proxy_dir_conf *, const char *);
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb#elif defined(PROXY_DECLARE_STATIC)
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbbtypedef const char *(__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb proxy_dir_conf *, const char *);
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb#elif defined(PROXY_DECLARE_EXPORT)
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbbtypedef __declspec(dllexport) const char *
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb (__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
561e5f16a2f9fb397aac4c283aaa87a752520a4ddougm proxy_dir_conf *, const char *);
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb#else
561e5f16a2f9fb397aac4c283aaa87a752520a4ddougmtypedef __declspec(dllimport) const char *
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb (__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb proxy_dir_conf *, const char *);
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb#endif
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb/* Connection pool API */
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb/**
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb * Get the worker from proxy configuration
561e5f16a2f9fb397aac4c283aaa87a752520a4ddougm * @param p memory pool used for finding worker
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb * @param balancer the balancer that the worker belongs to
561e5f16a2f9fb397aac4c283aaa87a752520a4ddougm * @param conf current proxy server configuration
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb * @param url url to find the worker from
fcc25eda7b150e226d3c1cdaea66a943d3fdee4erbb * @return proxy_worker or NULL if not found
c9a95767fbf0f5fb0976a06b97a256033925e433rbb */
c9a95767fbf0f5fb0976a06b97a256033925e433rbbPROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
c9a95767fbf0f5fb0976a06b97a256033925e433rbb proxy_balancer *balancer,
c9a95767fbf0f5fb0976a06b97a256033925e433rbb proxy_server_conf *conf,
c9a95767fbf0f5fb0976a06b97a256033925e433rbb const char *url);
c9a95767fbf0f5fb0976a06b97a256033925e433rbb/**
c9a95767fbf0f5fb0976a06b97a256033925e433rbb * Define and Allocate space for the worker to proxy configuration
c9a95767fbf0f5fb0976a06b97a256033925e433rbb * @param p memory pool to allocate worker from
c9a95767fbf0f5fb0976a06b97a256033925e433rbb * @param worker the new worker
c9a95767fbf0f5fb0976a06b97a256033925e433rbb * @param balancer the balancer that the worker belongs to
c9a95767fbf0f5fb0976a06b97a256033925e433rbb * @param conf current proxy server configuration
c9a95767fbf0f5fb0976a06b97a256033925e433rbb * @param url url containing worker name
c9a95767fbf0f5fb0976a06b97a256033925e433rbb * @param do_malloc true if shared struct should be malloced
2d2eda71267231c2526be701fe655db125852c1ffielding * @return error message or NULL if successful (*worker is new worker)
2d2eda71267231c2526be701fe655db125852c1ffielding */
2d2eda71267231c2526be701fe655db125852c1ffieldingPROXY_DECLARE(char *) ap_proxy_define_worker(apr_pool_t *p,
2d2eda71267231c2526be701fe655db125852c1ffielding proxy_worker **worker,
2d2eda71267231c2526be701fe655db125852c1ffielding proxy_balancer *balancer,
proxy_server_conf *conf,
const char *url,
int do_malloc);
/**
* Share a defined proxy worker via shm
* @param worker worker to be shared
* @param shm location of shared info
* @param i index into shm
* @return APR_SUCCESS or error code
*/
PROXY_DECLARE(apr_status_t) ap_proxy_share_worker(proxy_worker *worker,
proxy_worker_shared *shm,
int i);
/**
* Initialize the worker by setting up worker connection pool and mutex
* @param worker worker to initialize
* @param s current server record
* @param p memory pool used for mutex and connection pool
* @return APR_SUCCESS or error code
*/
PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker,
server_rec *s,
apr_pool_t *p);
/**
* Verifies valid balancer name (eg: balancer://foo)
* @param name name to test
* @param i number of chars to test; 0 for all.
* @return true/false
*/
PROXY_DECLARE(int) ap_proxy_valid_balancer_name(char *name, int i);
/**
* Get the balancer from proxy configuration
* @param p memory pool used for temporary storage while finding balancer
* @param conf current proxy server configuration
* @param url url to find the worker from; must have balancer:// prefix
* @param careactive true if we care if the balancer is active or not
* @return proxy_balancer or NULL if not found
*/
PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
proxy_server_conf *conf,
const char *url,
int careactive);
/**
* Update the balancer's vhost related fields
* @param p memory pool used for temporary storage while finding balancer
* @param balancer balancer to be updated
* @param url url to find vhost info
* @return error string or NULL if OK
*/
PROXY_DECLARE(char *) ap_proxy_update_balancer(apr_pool_t *p,
proxy_balancer *balancer,
const char *url);
/**
* Define and Allocate space for the balancer to proxy configuration
* @param p memory pool to allocate balancer from
* @param balancer the new balancer
* @param conf current proxy server configuration
* @param url url containing balancer name
* @param alias alias/fake-path to this balancer
* @param do_malloc true if shared struct should be malloced
* @return error message or NULL if successfull
*/
PROXY_DECLARE(char *) ap_proxy_define_balancer(apr_pool_t *p,
proxy_balancer **balancer,
proxy_server_conf *conf,
const char *url,
const char *alias,
int do_malloc);
/**
* Share a defined proxy balancer via shm
* @param balancer balancer to be shared
* @param shm location of shared info
* @param i index into shm
* @return APR_SUCCESS or error code
*/
PROXY_DECLARE(apr_status_t) ap_proxy_share_balancer(proxy_balancer *balancer,
proxy_balancer_shared *shm,
int i);
/**
* Initialize the balancer as needed
* @param balancer balancer to initialize
* @param s current server record
* @param p memory pool used for mutex and connection pool
* @return APR_SUCCESS or error code
*/
PROXY_DECLARE(apr_status_t) ap_proxy_initialize_balancer(proxy_balancer *balancer,
server_rec *s,
apr_pool_t *p);
/**
* Find the shm of the worker as needed
* @param storage slotmem provider
* @param slot slotmem instance
* @param worker worker to find
* @param index pointer to index within slotmem of worker
* @return pointer to shm of worker, or NULL
*/
PROXY_DECLARE(proxy_worker_shared *) ap_proxy_find_workershm(ap_slotmem_provider_t *storage,
ap_slotmem_instance_t *slot,
proxy_worker *worker,
unsigned int *index);
/**
* Find the shm of the balancer as needed
* @param storage slotmem provider
* @param slot slotmem instance
* @param worker worker to find
* @param index pointer to index within slotmem of balancer
* @return pointer to shm of balancer, or NULL
*/
PROXY_DECLARE(proxy_balancer_shared *) ap_proxy_find_balancershm(ap_slotmem_provider_t *storage,
ap_slotmem_instance_t *slot,
proxy_balancer *balancer,
unsigned int *index);
/**
* Get the most suitable worker and/or balancer for the request
* @param worker worker used for processing request
* @param balancer balancer used for processing request
* @param r current request
* @param conf current proxy server configuration
* @param url request url that balancer can rewrite.
* @return OK or HTTP_XXX error
* @note It calls balancer pre_request hook if the url starts with balancer://
* The balancer then rewrites the url to particular worker, like http://host:port
*/
PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
proxy_balancer **balancer,
request_rec *r,
proxy_server_conf *conf,
char **url);
/**
* Post request worker and balancer cleanup
* @param worker worker used for processing request
* @param balancer balancer used for processing request
* @param r current request
* @param conf current proxy server configuration
* @return OK or HTTP_XXX error
* @note Whenever the pre_request is called, the post_request has to be
* called too.
*/
PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker,
proxy_balancer *balancer,
request_rec *r,
proxy_server_conf *conf);
/**
* Determine backend hostname and port
* @param p memory pool used for processing
* @param r current request
* @param conf current proxy server configuration
* @param worker worker used for processing request
* @param conn proxy connection struct
* @param uri processed uri
* @param url request url
* @param proxyname are we connecting directly or via a proxy
* @param proxyport proxy host port
* @param server_portstr Via headers server port
* @param server_portstr_size size of the server_portstr buffer
* @return OK or HTTP_XXX error
*/
PROXY_DECLARE(int) ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
proxy_server_conf *conf,
proxy_worker *worker,
proxy_conn_rec *conn,
apr_uri_t *uri,
char **url,
const char *proxyname,
apr_port_t proxyport,
char *server_portstr,
int server_portstr_size);
/**
* Mark a worker for retry
* @param proxy_function calling proxy scheme (http, ajp, ...)
* @param worker worker used for retrying
* @param s current server record
* @return OK if marked for retry, DECLINED otherwise
* @note The error status of the worker will cleared if the retry interval has
* elapsed since the last error.
*/
APR_DECLARE_OPTIONAL_FN(int, ap_proxy_retry_worker,
(const char *proxy_function, proxy_worker *worker, server_rec *s));
/**
* Acquire a connection from worker connection pool
* @param proxy_function calling proxy scheme (http, ajp, ...)
* @param conn acquired connection
* @param worker worker used for obtaining connection
* @param s current server record
* @return OK or HTTP_XXX error
* @note If the connection limit has been reached, the function will
* block until a connection becomes available or the timeout has
* elapsed.
*/
PROXY_DECLARE(int) ap_proxy_acquire_connection(const char *proxy_function,
proxy_conn_rec **conn,
proxy_worker *worker,
server_rec *s);
/**
* Release a connection back to worker connection pool
* @param proxy_function calling proxy scheme (http, ajp, ...)
* @param conn acquired connection
* @param s current server record
* @return OK or HTTP_XXX error
* @note The connection will be closed if conn->close_on_release is set
*/
PROXY_DECLARE(int) ap_proxy_release_connection(const char *proxy_function,
proxy_conn_rec *conn,
server_rec *s);
/**
* Make a connection to the backend
* @param proxy_function calling proxy scheme (http, ajp, ...)
* @param conn acquired connection
* @param worker connection worker
* @param s current server record
* @return OK or HTTP_XXX error
* @note In case the socket already exists for conn, just check the link
* status.
*/
PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
proxy_conn_rec *conn,
proxy_worker *worker,
server_rec *s);
/**
* Make a connection record for backend connection
* @param proxy_function calling proxy scheme (http, ajp, ...)
* @param conn acquired connection
* @param c client connection record
* @param s current server record
* @return OK or HTTP_XXX error
* @note The function will return immediately if conn->connection
* is already set,
*/
PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,
proxy_conn_rec *conn,
conn_rec *c, server_rec *s);
/**
* Signal the upstream chain that the connection to the backend broke in the
* middle of the response. This is done by sending an error bucket with
* status HTTP_BAD_GATEWAY and an EOS bucket up the filter chain.
* @param r current request record of client request
* @param brigade The brigade that is sent through the output filter chain
*/
PROXY_DECLARE(void) ap_proxy_backend_broke(request_rec *r,
apr_bucket_brigade *brigade);
/**
* Return a hash based on the passed string
* @param str string to produce hash from
* @param method hashing method to use
* @return hash as unsigned int
*/
typedef enum { PROXY_HASHFUNC_DEFAULT, PROXY_HASHFUNC_APR, PROXY_HASHFUNC_FNV } proxy_hash_t;
PROXY_DECLARE(unsigned int) ap_proxy_hashfunc(const char *str, proxy_hash_t method);
/**
* Set/unset the worker status bitfield depending on flag
* @param c flag
* @param set set or unset bit
* @param w worker to use
* @return APR_SUCCESS if valid flag
*/
PROXY_DECLARE(apr_status_t) ap_proxy_set_wstatus(char c, int set, proxy_worker *w);
/**
* Create readable representation of worker status bitfield
* @param p pool
* @param w worker to use
* @return string representation of status
*/
PROXY_DECLARE(char *) ap_proxy_parse_wstatus(apr_pool_t *p, proxy_worker *w);
/**
* Sync balancer and workers based on any updates w/i shm
* @param b balancer to check/update member list of
* @param s server rec
* @param conf config
* @return APR_SUCCESS if all goes well
*/
PROXY_DECLARE(apr_status_t) ap_proxy_sync_balancer(proxy_balancer *b,
server_rec *s,
proxy_server_conf *conf);
/**
* Find the matched alias for this request and setup for proxy handler
* @param r request
* @param ent proxy_alias record
* @param dconf per-dir config or NULL
* @return DECLINED, DONE or OK if matched
*/
PROXY_DECLARE(int) ap_proxy_trans_match(request_rec *r,
struct proxy_alias *ent,
proxy_dir_conf *dconf);
#define PROXY_LBMETHOD "proxylbmethod"
/* The number of dynamic workers that can be added when reconfiguring.
* If this limit is reached you must stop and restart the server.
*/
#define PROXY_DYNAMIC_BALANCER_LIMIT 16
/**
* Calculate maximum number of workers in scoreboard.
* @return number of workers to allocate in the scoreboard
*/
int ap_proxy_lb_workers(void);
extern module PROXY_DECLARE_DATA proxy_module;
#endif /*MOD_PROXY_H*/
/** @} */