mod_proxy.h revision 56c721887b9c93721a7fe3afc45c89a94e3f07c1
252N/A/* Licensed to the Apache Software Foundation (ASF) under one or more 252N/A * contributor license agreements. See the NOTICE file distributed with 252N/A * this work for additional information regarding copyright ownership. 252N/A * The ASF licenses this file to You under the Apache License, Version 2.0 252N/A * (the "License"); you may not use this file except in compliance with 252N/A * the License. You may obtain a copy of the License at 252N/A * Unless required by applicable law or agreed to in writing, software 252N/A * distributed under the License is distributed on an "AS IS" BASIS, 252N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 252N/A * See the License for the specific language governing permissions and 252N/A * limitations under the License. 252N/A * @brief Proxy Extension Module for Apache 252N/A * @defgroup MOD_PROXY mod_proxy 252N/A/* for proxy_canonenc() */ 252N/A#
else /*APR_CHARSET_EBCDIC*/ 252N/A#
endif /*APR_CHARSET_EBCDIC*/ 252N/A/* default Max-Forwards header setting */ 252N/A/* Set this to -1, which complies with RFC2616 by not setting 252N/A * max-forwards if the client didn't send it to us. 252N/A/* static information about a remote proxy */ 252N/A const char *
scheme;
/* the schemes handled by this proxy, or '*' */ 252N/A const char *
protocol;
/* the scheme used to talk to this proxy */ 252N/A int use_regex;
/* simple boolean. True if we have a regex pattern */ const char *
domain;
/* domain name to use in absence of a domain name in the request */ apr_pool_t *
pool;
/* Pool used for allocating this struct's elements */ int req;
/* true if proxy requests are enabled */ int bgrowth;
/* number of post-config balancers can added */ }
viaopt;
/* how to deal with proxy Via: headers */ }
badopt;
/* how to deal with bad headers */ const char *p;
/* The path */ * ProxyPassReverse and friends are documented as working inside * <Location>. But in fact they never have done in the case of * more than one <Location>, because the server_conf can't see it. * We need to move them to the per-dir config. * Discussed in February 2005: signed char p_is_fnmatch;
/* Is the path an fnmatch candidate? */ * the following setting masks the error page * returned from the 'proxied server' and just * forwards the status code upwards. * This allows the main server (us) to generate * the error page, (so it will look like a error * returned from the rest of the system /* if we interpolate env vars per-request, we'll need a per-request * copy of the reverse proxy config request_rec *r;
/* Request record of the backend request * that is used over the backend connection. */ const char *
uds_path;
/* Unix domain socket path */ void *
data;
/* per scheme connection data */ void *
forward;
/* opaque forward proxy data */ unsigned int close:
1;
/* Close 'this' connection */ unsigned int need_flush:
1;
/* Flag to decide whether we need to flush the unsigned int inreslist:
1;
/* connection in apr_reslist? */ apr_pool_t *
pool;
/* The pool used in constructor and destructor calls */ /* worker status flags */ /* NOTE: these check the shared status */ /* default worker retry timeout in seconds */ /* Some max char string sizes, for shm fields */ /* Runtime worker status informations. Shared in scoreboard */ int lbset;
/* load balancer cluster set */ int retries;
/* number of retries on this worker */ int min;
/* Desired minimum number of available connections */ int smax;
/* Soft maximum on the total number of connections */ int hmax;
/* Hard maximum on the total number of connections */ int flush_wait;
/* poll wait time in microseconds if flush_auto */ int index;
/* shm array index */ unsigned int status;
/* worker status bitfield */ * may be available while exceeding the soft limit */ void *
context;
/* general purpose storage */ /* Worker configuration */ unsigned int local_status;
/* status of per-process worker */ void *
context;
/* general purpose storage */ * Time to wait (in microseconds) to find out if more data is currently * available at the backend. int index;
/* shm array index */ unsigned int sticky_force:
1;
/* Disable failover for sticky sessions */ unsigned int scolonsep:
1;
/* true if ';' seps sticky session paths */ int growth;
/* number of post-config workers can added */ int max_workers;
/* maximum number of allowed workers */ void *
context;
/* general purpose storage */ int failontimeout;
/* Whether to mark a member in Err if IO timeout occurs */ const char *
name;
/* name of the load balancer method*/ void *
context;
/* general purpose storage */ /* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and * PROXY_DECLARE_DATA with appropriate export and import tags for the platform * It will return the most suitable worker at the moment * and coresponding balancer. * and then the scheme_handler is called. * It is called after request for updating runtime balancer status. * It is called after all proxy processing has been done. This gives other * modules a chance to create default content on failure, for example /** Test whether the hostname/address of the request are blocked by the ProxyBlock * @param conf server configuration * @param hostname hostname from request URI * @param addr resolved address of hostname, or NULL if not known * @return OK on success, or else an errro /* DEPRECATED (will be replaced with ap_proxy_connect_backend */ /* Header mapping functions, and a typedef of their signature */ /* Connection pool API */ * Get the worker from proxy configuration * @param p memory pool used for finding worker * @param balancer the balancer that the worker belongs to * @param conf current proxy server configuration * @param url url to find the worker from * @return proxy_worker or NULL if not found * Define and Allocate space for the worker to proxy configuration * @param p memory pool to allocate worker from * @param worker the new worker * @param balancer the balancer that the worker belongs to * @param conf current proxy server configuration * @param url url containing worker name * @param do_malloc true if shared struct should be malloced * @return error message or NULL if successful (*worker is new worker) * 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 * 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 * Verifies valid balancer name (eg: balancer://foo) * @param name name to test * @param i number of chars to test; 0 for all. * 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 * 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 * 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 do_malloc true if shared struct should be malloced * @return error message or NULL if successfull * 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 * 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 * 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 * Find the shm of the balancer as needed * @param storage slotmem provider * @param slot slotmem instance * @param balancer balancer of shm to find * @param index pointer to index within slotmem of balancer * @return pointer to shm of balancer, or NULL * 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 * 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 * 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 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 * 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. * 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 * 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 * 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 * 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 * 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 * @deprecated To be removed in v2.6. * 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 * Set/unset the worker status bitfield depending on flag * @param set set or unset bit * @return APR_SUCCESS if valid flag * Create readable representation of worker status bitfield * @return string representation of status * Sync balancer and workers based on any updates w/i shm * @return APR_SUCCESS if all goes well * Find the matched alias for this request and setup for proxy handler * @param ent proxy_alias record * @param dconf per-dir config or NULL * @return DECLINED, DONE or OK if matched * Create a HTTP request header brigade, old_cl_val and old_te_val as required. * @param header_brigade header brigade to use/fill * @param p_conn proxy connection rec * @param worker selected worker * @param conf per-server proxy config * @param server_portstr port as string * @param old_cl_val stored old content-len val * @param old_te_val stored old TE val * @return OK or HTTP_EXPECTATION_FAILED * @param bucket_alloc bucket allocator * @param p_conn proxy connection * @param origin connection rec of origin * @param bb brigade to send to origin * Clear the headers referenced by the Connection header from the given * table, and remove the Connection header. * @param headers table of headers to clear * @return 1 if "close" was present, 0 otherwise. * @param socket socket to test /* The number of dynamic workers that can be added when reconfiguring. * If this limit is reached you must stop and restart the server. * Calculate maximum number of workers in scoreboard. * @return number of workers to allocate in the scoreboard