1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 * @brief Proxy Extension Module for Apache
24 * @defgroup MOD_PROXY mod_proxy
25 * @ingroup APACHE_MODS
31 Also note numerous FIXMEs and CHECKMEs which should be eliminated.
33 This code is once again experimental!
37 1. Make it completely work (for FTP too)
41 Chuck Murcko <chuck@topsail.org> 02-06-01
47 #include "apr_hooks.h"
50 #include "apr_strings.h"
51 #include "apr_buckets.h"
53 #include "apr_network_io.h"
54 #include "apr_pools.h"
55 #include "apr_strings.h"
58 #include "apr_strmatch.h"
59 #include "apr_fnmatch.h"
60 #include "apr_reslist.h"
61 #define APR_WANT_STRFUNC
65 #include "http_config.h"
66 #include "ap_config.h"
67 #include "http_core.h"
68 #include "http_protocol.h"
69 #include "http_request.h"
70 #include "http_vhost.h"
71 #include "http_main.h"
73 #include "http_connection.h"
74 #include "util_filter.h"
75 #include "util_ebcdic.h"
76 #include "ap_provider.h"
78 #if APR_HAVE_NETINET_IN_H
79 #include <netinet/in.h>
81 #if APR_HAVE_ARPA_INET_H
82 #include <arpa/inet.h>
85 /* for proxy_canonenc() */
87 enc_path, enc_search, enc_user, enc_fpath, enc_parm
90 #if APR_CHARSET_EBCDIC
92 #else /*APR_CHARSET_EBCDIC*/
93 #define CRLF "\015\012"
94 #endif /*APR_CHARSET_EBCDIC*/
96 /* default Max-Forwards header setting */
97 #define DEFAULT_MAX_FORWARDS 10
99 /* static information about a remote proxy */
100 struct proxy_remote {
101 const char *scheme; /* the schemes handled by this proxy, or '*' */
102 const char *protocol; /* the scheme used to talk to this proxy */
103 const char *hostname; /* the hostname of this proxy */
104 apr_port_t port; /* the port for this proxy */
105 ap_regex_t *regexp; /* compiled regex (if any) for the remote */
106 int use_regex; /* simple boolean. True if we have a regex pattern */
115 struct dirconn_entry {
117 struct in_addr addr, mask;
118 struct apr_sockaddr_t *hostaddr;
119 int (*matcher) (struct dirconn_entry * This, request_rec *r);
122 struct noproxy_entry {
124 struct apr_sockaddr_t *addr;
127 typedef struct proxy_balancer proxy_balancer;
128 typedef struct proxy_worker proxy_worker;
129 typedef struct proxy_conn_pool proxy_conn_pool;
130 typedef struct proxy_balancer_method proxy_balancer_method;
133 apr_array_header_t *proxies;
134 apr_array_header_t *sec_proxy;
135 apr_array_header_t *aliases;
136 apr_array_header_t *noproxies;
137 apr_array_header_t *dirconn;
138 apr_array_header_t *allowed_connect_ports;
139 apr_array_header_t *workers;
140 apr_array_header_t *balancers;
141 proxy_worker *forward; /* forward proxy worker */
142 proxy_worker *reverse; /* reverse "module-driven" proxy worker */
143 const char *domain; /* domain name to use in absence of a domain name in the request */
144 int req; /* true if proxy requests are enabled */
151 } viaopt; /* how to deal with proxy Via: headers */
153 apr_size_t recv_buffer_size;
154 char recv_buffer_size_set;
155 apr_size_t io_buffer_size;
156 char io_buffer_size_set;
160 * the following setting masks the error page
161 * returned from the 'proxied server' and just
162 * forwards the status code upwards.
163 * This allows the main server (us) to generate
164 * the error page, (so it will look like a error
165 * returned from the rest of the system
168 int error_override_set;
170 int preserve_host_set;
171 apr_interval_time_t timeout;
177 } badopt; /* how to deal with bad headers */
179 /* putting new stuff on the end maximises binary back-compatibility.
180 * the strmatch_patterns are really a const just to have a
181 * case-independent strstr.
187 } proxy_status; /* Status display options */
188 char proxy_status_set;
189 apr_pool_t *pool; /* Pool used for allocating this struct */
194 const char *p; /* The path */
195 int p_is_fnmatch; /* Is this path an fnmatch candidate? */
196 ap_regex_t *r; /* Is this a regex? */
198 /* ProxyPassReverse and friends are documented as working inside
199 * <Location>. But in fact they never have done in the case of
200 * more than one <Location>, because the server_conf can't see it.
201 * We need to move them to the per-dir config.
202 * Discussed in February:
203 * http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=110726027118798&w=2
205 apr_array_header_t *raliases;
206 apr_array_header_t* cookie_paths;
207 apr_array_header_t* cookie_domains;
208 const apr_strmatch_pattern* cookie_path_str;
209 const apr_strmatch_pattern* cookie_domain_str;
213 /* if we interpolate env vars per-request, we'll need a per-request
214 * copy of the reverse proxy config
217 apr_array_header_t *raliases;
218 apr_array_header_t* cookie_paths;
219 apr_array_header_t* cookie_domains;
223 conn_rec *connection;
224 const char *hostname;
227 apr_pool_t *pool; /* Subpool used for creating socket */
228 apr_socket_t *sock; /* Connection socket */
229 apr_sockaddr_t *addr; /* Preparsed remote address info */
230 apr_uint32_t flags; /* Conection flags */
231 int close; /* Close 'this' connection */
232 proxy_worker *worker; /* Connection pool this connection belongs to */
233 void *data; /* per scheme connection data */
235 int inreslist; /* connection in apr_reslist? */
240 float cache_completion; /* completion percentage */
241 int content_length; /* length of the content */
244 /* Connection pool */
245 struct proxy_conn_pool {
246 apr_pool_t *pool; /* The pool used in constructor and destructor calls */
247 apr_sockaddr_t *addr; /* Preparsed remote address info */
249 apr_reslist_t *res; /* Connection resource list */
251 proxy_conn_rec *conn; /* Single connection for prefork mpm's */
254 /* worker status flags */
255 #define PROXY_WORKER_INITIALIZED 0x0001
256 #define PROXY_WORKER_IGNORE_ERRORS 0x0002
257 #define PROXY_WORKER_IN_SHUTDOWN 0x0010
258 #define PROXY_WORKER_DISABLED 0x0020
259 #define PROXY_WORKER_STOPPED 0x0040
260 #define PROXY_WORKER_IN_ERROR 0x0080
261 #define PROXY_WORKER_HOT_STANDBY 0x0100
263 #define PROXY_WORKER_NOT_USABLE_BITMAP ( PROXY_WORKER_IN_SHUTDOWN | \
264 PROXY_WORKER_DISABLED | PROXY_WORKER_STOPPED | PROXY_WORKER_IN_ERROR )
266 #define PROXY_WORKER_IS_INITIALIZED(f) ( (f)->s->status & \
267 PROXY_WORKER_INITIALIZED )
269 #define PROXY_WORKER_IS_STANDBY(f) ( (f)->s->status & \
270 PROXY_WORKER_HOT_STANDBY )
272 #define PROXY_WORKER_IS_USABLE(f) ( !((f)->s->status & \
273 (PROXY_WORKER_NOT_USABLE_BITMAP)) && PROXY_WORKER_IS_INITIALIZED(f) )
275 /* default worker retry timeout in seconds */
276 #define PROXY_WORKER_DEFAULT_RETRY 60
277 #define PROXY_WORKER_MAX_ROUTE_SIZ 63
279 /* Runtime worker status informations. Shared in scoreboard */
282 apr_time_t error_time; /* time of the last error */
283 int retries; /* number of retries on this worker */
284 int lbstatus; /* Current lbstatus */
285 int lbfactor; /* dynamic lbfactor */
286 apr_off_t transferred;/* Number of bytes transferred to remote */
287 apr_off_t read; /* Number of bytes read from remote */
288 apr_size_t elected; /* Number of times the worker was elected */
289 char route[PROXY_WORKER_MAX_ROUTE_SIZ+1];
290 char redirect[PROXY_WORKER_MAX_ROUTE_SIZ+1];
291 void *context; /* general purpose storage */
292 apr_size_t busy; /* busyness factor */
293 int lbset; /* load balancer cluster set */
296 /* Worker configuration */
297 struct proxy_worker {
298 int id; /* scoreboard id */
299 apr_interval_time_t retry; /* retry interval */
300 int lbfactor; /* initial load balancing factor */
302 const char *scheme; /* scheme to use ajp|http|https */
303 const char *hostname; /* remote backend address */
304 const char *route; /* balancing route */
305 const char *redirect; /* temporary balancing redirection route */
306 int status; /* temporary worker status */
308 int min; /* Desired minimum number of available connections */
309 int smax; /* Soft maximum on the total number of connections */
310 int hmax; /* Hard maximum on the total number of connections */
311 apr_interval_time_t ttl; /* maximum amount of time in seconds a connection
312 * may be available while exceeding the soft limit */
313 apr_interval_time_t timeout; /* connection timeout */
315 apr_interval_time_t acquire; /* acquire timeout when the maximum number of connections is exceeded */
317 apr_size_t recv_buffer_size;
318 char recv_buffer_size_set;
319 apr_size_t io_buffer_size;
320 char io_buffer_size_set;
323 proxy_conn_pool *cp; /* Connection pool to use */
324 proxy_worker_stat *s; /* Shared data */
325 void *opaque; /* per scheme worker data */
326 int is_address_reusable;
328 apr_thread_mutex_t *mutex; /* Thread lock for updating address cache */
330 void *context; /* general purpose storage */
335 } flush_packets; /* control AJP flushing */
336 int flush_wait; /* poll wait time in microseconds if flush_auto */
337 apr_interval_time_t ping_timeout;
338 char ping_timeout_set;
339 int lbset; /* load balancer cluster set */
344 * Wait 10000 microseconds to find out if more data is currently
345 * available at the backend. Just an arbitrary choose.
347 #define PROXY_FLUSH_WAIT 10000
349 struct proxy_balancer {
350 apr_array_header_t *workers; /* array of proxy_workers */
351 const char *name; /* name of the load balancer */
352 const char *sticky; /* sticky session identifier */
353 int sticky_force; /* Disable failover for sticky sessions */
354 apr_interval_time_t timeout; /* Timeout for waiting on free connection */
355 int max_attempts; /* Number of attempts before failing */
356 char max_attempts_set;
357 proxy_balancer_method *lbmethod;
359 /* XXX: Perhaps we will need the proc mutex too.
360 * Altrough we are only using arithmetic operations
361 * it may lead to a incorrect calculations.
362 * For now use only the thread mutex.
365 apr_thread_mutex_t *mutex; /* Thread lock for updating lb params */
367 void *context; /* general purpose storage */
370 struct proxy_balancer_method {
371 const char *name; /* name of the load balancer method*/
372 proxy_worker *(*finder)(proxy_balancer *balancer,
374 void *context; /* general purpose storage */
378 #define PROXY_THREAD_LOCK(x) apr_thread_mutex_lock((x)->mutex)
379 #define PROXY_THREAD_UNLOCK(x) apr_thread_mutex_unlock((x)->mutex)
381 #define PROXY_THREAD_LOCK(x) APR_SUCCESS
382 #define PROXY_THREAD_UNLOCK(x) APR_SUCCESS
387 /* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and
388 * PROXY_DECLARE_DATA with appropriate export and import tags for the platform
391 #define PROXY_DECLARE(type) type
392 #define PROXY_DECLARE_NONSTD(type) type
393 #define PROXY_DECLARE_DATA
394 #elif defined(PROXY_DECLARE_STATIC)
395 #define PROXY_DECLARE(type) type __stdcall
396 #define PROXY_DECLARE_NONSTD(type) type
397 #define PROXY_DECLARE_DATA
398 #elif defined(PROXY_DECLARE_EXPORT)
399 #define PROXY_DECLARE(type) __declspec(dllexport) type __stdcall
400 #define PROXY_DECLARE_NONSTD(type) __declspec(dllexport) type
401 #define PROXY_DECLARE_DATA __declspec(dllexport)
403 #define PROXY_DECLARE(type) __declspec(dllimport) type __stdcall
404 #define PROXY_DECLARE_NONSTD(type) __declspec(dllimport) type
405 #define PROXY_DECLARE_DATA __declspec(dllimport)
409 * Hook an optional proxy hook. Unlike static hooks, this uses a macro
410 * instead of a function.
412 #define PROXY_OPTIONAL_HOOK(name,fn,pre,succ,order) \
413 APR_OPTIONAL_HOOK(proxy,name,fn,pre,succ,order)
415 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
416 proxy_worker *worker, proxy_server_conf *conf, char *url,
417 const char *proxyhost, apr_port_t proxyport))
418 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r,
421 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr))
422 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, fixups, (request_rec *r))
426 * It will return the most suitable worker at the moment
427 * and coresponding balancer.
428 * The url is rewritten from balancer://cluster/uri to scheme://host:port/uri
429 * and then the scheme_handler is called.
432 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, pre_request, (proxy_worker **worker,
433 proxy_balancer **balancer,
435 proxy_server_conf *conf, char **url))
438 * It is called after request for updating runtime balancer status.
440 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, post_request, (proxy_worker *worker,
441 proxy_balancer *balancer, request_rec *r,
442 proxy_server_conf *conf))
445 * request status hook
446 * It is called after all proxy processing has been done. This gives other
447 * modules a chance to create default content on failure, for example
449 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, request_status,
450 (int *status, request_rec *r))
454 PROXY_DECLARE(request_rec *)ap_proxy_make_fake_req(conn_rec *c, request_rec *r);
455 PROXY_DECLARE(int) ap_proxy_hex2c(const char *x);
456 PROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x);
457 PROXY_DECLARE(char *)ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t,
458 int forcedec, int proxyreq);
459 PROXY_DECLARE(char *)ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp,
460 char **passwordp, char **hostp, apr_port_t *port);
461 PROXY_DECLARE(const char *)ap_proxy_date_canon(apr_pool_t *p, const char *x);
462 PROXY_DECLARE(int) ap_proxy_liststr(const char *list, const char *val);
463 PROXY_DECLARE(char *)ap_proxy_removestr(apr_pool_t *pool, const char *list, const char *val);
464 PROXY_DECLARE(int) ap_proxy_hex2sec(const char *x);
465 PROXY_DECLARE(void) ap_proxy_sec2hex(int t, char *y);
466 PROXY_DECLARE(int) ap_proxyerror(request_rec *r, int statuscode, const char *message);
467 PROXY_DECLARE(int) ap_proxy_is_ipaddr(struct dirconn_entry *This, apr_pool_t *p);
468 PROXY_DECLARE(int) ap_proxy_is_domainname(struct dirconn_entry *This, apr_pool_t *p);
469 PROXY_DECLARE(int) ap_proxy_is_hostname(struct dirconn_entry *This, apr_pool_t *p);
470 PROXY_DECLARE(int) ap_proxy_is_word(struct dirconn_entry *This, apr_pool_t *p);
471 PROXY_DECLARE(int) ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf, apr_sockaddr_t *uri_addr);
472 PROXY_DECLARE(int) ap_proxy_pre_http_request(conn_rec *c, request_rec *r);
473 PROXY_DECLARE(apr_status_t) ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb, char *buff, size_t bufflen, int *eos);
474 PROXY_DECLARE(void) ap_proxy_table_unmerge(apr_pool_t *p, apr_table_t *t, char *key);
475 /* DEPRECATED (will be replaced with ap_proxy_connect_backend */
476 PROXY_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 *);
477 PROXY_DECLARE(int) ap_proxy_ssl_enable(conn_rec *c);
478 PROXY_DECLARE(int) ap_proxy_ssl_disable(conn_rec *c);
479 PROXY_DECLARE(int) ap_proxy_conn_is_https(conn_rec *c);
480 PROXY_DECLARE(const char *) ap_proxy_ssl_val(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r, const char *var);
482 /* Header mapping functions, and a typedef of their signature */
483 PROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *url);
484 PROXY_DECLARE(const char *) ap_proxy_cookie_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *str);
487 typedef const char *(*ap_proxy_header_reverse_map_fn)(request_rec *,
488 proxy_dir_conf *, const char *);
489 #elif defined(PROXY_DECLARE_STATIC)
490 typedef const char *(__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
491 proxy_dir_conf *, const char *);
492 #elif defined(PROXY_DECLARE_EXPORT)
493 typedef __declspec(dllexport) const char *
494 (__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
495 proxy_dir_conf *, const char *);
497 typedef __declspec(dllimport) const char *
498 (__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
499 proxy_dir_conf *, const char *);
503 /* Connection pool API */
505 * Get the worker from proxy configuration
506 * @param p memory pool used for finding worker
507 * @param conf current proxy server configuration
508 * @param url url to find the worker from
509 * @return proxy_worker or NULL if not found
511 PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
512 proxy_server_conf *conf,
515 * Add the worker to proxy configuration
516 * @param worker the new worker
517 * @param p memory pool to allocate worker from
518 * @param conf current proxy server configuration
519 * @param url url containing worker name
520 * @return error message or NULL if successfull
522 PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker,
524 proxy_server_conf *conf,
529 * @param p memory pool to allocate worker from
532 PROXY_DECLARE(proxy_worker *) ap_proxy_create_worker(apr_pool_t *p);
535 * Initize the worker's shared data
536 * @param conf current proxy server configuration
537 * @param worker worker to initialize
538 * @param s current server record
539 * @param worker worker to initialize
541 PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf,
542 proxy_worker *worker,
548 * @param worker worker to initialize
549 * @param s current server record
550 * @return APR_SUCCESS or error code
552 PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker,
555 * Get the balancer from proxy configuration
556 * @param p memory pool used for finding balancer
557 * @param conf current proxy server configuration
558 * @param url url to find the worker from. Has to have balancer:// prefix
559 * @return proxy_balancer or NULL if not found
561 PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
562 proxy_server_conf *conf,
565 * Add the balancer to proxy configuration
566 * @param balancer the new balancer
567 * @param p memory pool to allocate balancer from
568 * @param conf current proxy server configuration
569 * @param url url containing balancer name
570 * @return error message or NULL if successfull
572 PROXY_DECLARE(const char *) ap_proxy_add_balancer(proxy_balancer **balancer,
574 proxy_server_conf *conf,
578 * Add the worker to the balancer
579 * @param pool memory pool for adding worker
580 * @param balancer balancer to add to
581 * @param balancer worker to add
582 * @note Single worker can be added to multiple balancers.
584 PROXY_DECLARE(void) ap_proxy_add_worker_to_balancer(apr_pool_t *pool,
585 proxy_balancer *balancer,
586 proxy_worker *worker);
588 * Get the most suitable worker and(or) balancer for the request
589 * @param worker worker used for processing request
590 * @param balancer balancer used for processing request
591 * @param r current request
592 * @param conf current proxy server configuration
593 * @param url request url that balancer can rewrite.
594 * @return OK or HTTP_XXX error
595 * @note It calls balancer pre_request hook if the url starts with balancer://
596 * The balancer then rewrites the url to particular worker, like http://host:port
598 PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
599 proxy_balancer **balancer,
601 proxy_server_conf *conf,
604 * Post request worker and balancer cleanup
605 * @param worker worker used for processing request
606 * @param balancer balancer used for processing request
607 * @param r current request
608 * @param conf current proxy server configuration
609 * @return OK or HTTP_XXX error
610 * @note When ever the pre_request is called, the post_request has to be
613 PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker,
614 proxy_balancer *balancer,
616 proxy_server_conf *conf);
619 * Request status function
620 * @param status status of proxy request
621 * @return OK or DECLINED
623 PROXY_DECLARE(int) ap_proxy_request_status(int *status, request_rec *r);
626 * Deternime backend hostname and port
627 * @param p memory pool used for processing
628 * @param r current request
629 * @param conf current proxy server configuration
630 * @param worker worker used for processing request
631 * @param conn proxy connection struct
632 * @param uri processed uri
633 * @param url request url
634 * @param proxyname are we connecting directly or via s proxy
635 * @param proxyport proxy host port
636 * @param server_portstr Via headers server port
637 * @param server_portstr_size size of the server_portstr buffer
638 * @return OK or HTTP_XXX error
640 PROXY_DECLARE(int) ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
641 proxy_server_conf *conf,
642 proxy_worker *worker,
643 proxy_conn_rec *conn,
646 const char *proxyname,
647 apr_port_t proxyport,
648 char *server_portstr,
649 int server_portstr_size);
651 * Mark a worker for retry
652 * @param proxy_function calling proxy scheme (http, ajp, ...)
653 * @param conf current proxy server configuration
654 * @param worker worker used for retrying
655 * @param s current server record
656 * @return OK if marked for retry, DECLINED otherwise
657 * @note Worker will be marker for retry if the time of the last retry
658 * has been ellapsed. In case there is no retry option set, defaults to
659 * number_of_retries seconds.
661 PROXY_DECLARE(int) ap_proxy_retry_worker(const char *proxy_function,
662 proxy_worker *worker,
665 * Acquire a connection from workers connection pool
666 * @param proxy_function calling proxy scheme (http, ajp, ...)
667 * @param conn acquired connection
668 * @param worker worker used for obtaining connection
669 * @param s current server record
670 * @return OK or HTTP_XXX error
671 * @note If the number of connections is exhaused the function will
672 * block untill the timeout is reached.
674 PROXY_DECLARE(int) ap_proxy_acquire_connection(const char *proxy_function,
675 proxy_conn_rec **conn,
676 proxy_worker *worker,
679 * Release a connection back to worker connection pool
680 * @param proxy_function calling proxy scheme (http, ajp, ...)
681 * @param conn acquired connection
682 * @param s current server record
683 * @return OK or HTTP_XXX error
684 * @note The connection will be closed if conn->close_on_release is set
686 PROXY_DECLARE(int) ap_proxy_release_connection(const char *proxy_function,
687 proxy_conn_rec *conn,
690 * Make a connection to the backend
691 * @param proxy_function calling proxy scheme (http, ajp, ...)
692 * @param conn acquired connection
693 * @param worker connection worker
694 * @param s current server record
695 * @return OK or HTTP_XXX error
696 * @note In case the socket already exists for conn, just check the link
699 PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
700 proxy_conn_rec *conn,
701 proxy_worker *worker,
704 * Make a connection record for backend connection
705 * @param proxy_function calling proxy scheme (http, ajp, ...)
706 * @param conn acquired connection
707 * @param c client connection record
708 * @param s current server record
709 * @return OK or HTTP_XXX error
711 PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,
712 proxy_conn_rec *conn,
713 conn_rec *c, server_rec *s);
715 * Signal the upstream chain that the connection to the backend broke in the
716 * middle of the response. This is done by sending an error bucket with
717 * status HTTP_BAD_GATEWAY and an EOS bucket up the filter chain.
718 * @param r current request record of client request
719 * @param brigade The brigade that is sent through the output filter chain
721 PROXY_DECLARE(void) ap_proxy_backend_broke(request_rec *r,
722 apr_bucket_brigade *brigade);
724 #define PROXY_LBMETHOD "proxylbmethod"
726 /* The number of dynamic workers that can be added when reconfiguring.
727 * If this limit is reached you must stop and restart the server.
729 #define PROXY_DYNAMIC_BALANCER_LIMIT 16
731 * Calculate number of maximum number of workers in scoreboard.
732 * @return number of workers to allocate in the scoreboard
734 int ap_proxy_lb_workers(void);
737 extern module PROXY_DECLARE_DATA proxy_module;
739 extern int PROXY_DECLARE_DATA proxy_lb_workers;
741 #endif /*MOD_PROXY_H*/