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 */
114 struct dirconn_entry {
116 struct in_addr addr, mask;
117 struct apr_sockaddr_t *hostaddr;
118 int (*matcher) (struct dirconn_entry * This, request_rec *r);
121 struct noproxy_entry {
123 struct apr_sockaddr_t *addr;
126 typedef struct proxy_balancer proxy_balancer;
127 typedef struct proxy_worker proxy_worker;
128 typedef struct proxy_conn_pool proxy_conn_pool;
129 typedef struct proxy_balancer_method proxy_balancer_method;
132 apr_array_header_t *proxies;
133 apr_array_header_t *sec_proxy;
134 apr_array_header_t *aliases;
135 apr_array_header_t *noproxies;
136 apr_array_header_t *dirconn;
137 apr_array_header_t *allowed_connect_ports;
138 apr_array_header_t *workers;
139 apr_array_header_t *balancers;
140 proxy_worker *forward; /* forward proxy worker */
141 proxy_worker *reverse; /* reverse "module-driven" proxy worker */
142 const char *domain; /* domain name to use in absence of a domain name in the request */
143 int req; /* true if proxy requests are enabled */
150 } viaopt; /* how to deal with proxy Via: headers */
152 apr_size_t recv_buffer_size;
153 char recv_buffer_size_set;
154 apr_size_t io_buffer_size;
155 char io_buffer_size_set;
159 * the following setting masks the error page
160 * returned from the 'proxied server' and just
161 * forwards the status code upwards.
162 * This allows the main server (us) to generate
163 * the error page, (so it will look like a error
164 * returned from the rest of the system
167 int error_override_set;
169 int preserve_host_set;
170 apr_interval_time_t timeout;
176 } badopt; /* how to deal with bad headers */
178 /* putting new stuff on the end maximises binary back-compatibility.
179 * the strmatch_patterns are really a const just to have a
180 * case-independent strstr.
186 } proxy_status; /* Status display options */
187 char proxy_status_set;
188 apr_pool_t *pool; /* Pool used for allocating this struct */
193 const char *p; /* The path */
194 int p_is_fnmatch; /* Is this path an fnmatch candidate? */
195 ap_regex_t *r; /* Is this a regex? */
197 /* ProxyPassReverse and friends are documented as working inside
198 * <Location>. But in fact they never have done in the case of
199 * more than one <Location>, because the server_conf can't see it.
200 * We need to move them to the per-dir config.
201 * Discussed in February:
202 * http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=110726027118798&w=2
204 apr_array_header_t *raliases;
205 apr_array_header_t* cookie_paths;
206 apr_array_header_t* cookie_domains;
207 const apr_strmatch_pattern* cookie_path_str;
208 const apr_strmatch_pattern* cookie_domain_str;
212 /* if we interpolate env vars per-request, we'll need a per-request
213 * copy of the reverse proxy config
216 apr_array_header_t *raliases;
217 apr_array_header_t* cookie_paths;
218 apr_array_header_t* cookie_domains;
222 conn_rec *connection;
223 const char *hostname;
226 apr_pool_t *pool; /* Subpool used for creating socket */
227 apr_socket_t *sock; /* Connection socket */
228 apr_sockaddr_t *addr; /* Preparsed remote address info */
229 apr_uint32_t flags; /* Conection flags */
230 int close; /* Close 'this' connection */
231 int close_on_recycle; /* Close the connection when returning to pool */
232 proxy_worker *worker; /* Connection pool this connection belogns 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 */
294 /* Worker configuration */
295 struct proxy_worker {
296 int id; /* scoreboard id */
297 apr_interval_time_t retry; /* retry interval */
298 int lbfactor; /* initial load balancing factor */
300 const char *scheme; /* scheme to use ajp|http|https */
301 const char *hostname; /* remote backend address */
302 const char *route; /* balancing route */
303 const char *redirect; /* temporary balancing redirection route */
304 int status; /* temporary worker status */
306 int min; /* Desired minimum number of available connections */
307 int smax; /* Soft maximum on the total number of connections */
308 int hmax; /* Hard maximum on the total number of connections */
309 apr_interval_time_t ttl; /* maximum amount of time in seconds a connection
310 * may be available while exceeding the soft limit */
311 apr_interval_time_t timeout; /* connection timeout */
313 apr_interval_time_t acquire; /* acquire timeout when the maximum number of connections is exceeded */
315 apr_size_t recv_buffer_size;
316 char recv_buffer_size_set;
317 apr_size_t io_buffer_size;
318 char io_buffer_size_set;
321 proxy_conn_pool *cp; /* Connection pool to use */
322 proxy_worker_stat *s; /* Shared data */
323 void *opaque; /* per scheme worker data */
324 int is_address_reusable;
326 apr_thread_mutex_t *mutex; /* Thread lock for updating address cache */
328 void *context; /* general purpose storage */
333 } flush_packets; /* control AJP flushing */
334 int flush_wait; /* poll wait time in microseconds if flush_auto */
335 apr_interval_time_t ping_timeout;
336 char ping_timeout_set;
340 * Wait 10000 microseconds to find out if more data is currently
341 * available at the backend. Just an arbitrary choose.
343 #define PROXY_FLUSH_WAIT 10000
345 struct proxy_balancer {
346 apr_array_header_t *workers; /* array of proxy_workers */
347 const char *name; /* name of the load balancer */
348 const char *sticky; /* sticky session identifier */
349 int sticky_force; /* Disable failover for sticky sessions */
350 apr_interval_time_t timeout; /* Timeout for waiting on free connection */
351 int max_attempts; /* Number of attempts before failing */
352 char max_attempts_set;
353 proxy_balancer_method *lbmethod;
355 /* XXX: Perhaps we will need the proc mutex too.
356 * Altrough we are only using arithmetic operations
357 * it may lead to a incorrect calculations.
358 * For now use only the thread mutex.
361 apr_thread_mutex_t *mutex; /* Thread lock for updating lb params */
363 void *context; /* general purpose storage */
366 struct proxy_balancer_method {
367 const char *name; /* name of the load balancer method*/
368 proxy_worker *(*finder)(proxy_balancer *balancer,
370 void *context; /* general purpose storage */
374 #define PROXY_THREAD_LOCK(x) apr_thread_mutex_lock((x)->mutex)
375 #define PROXY_THREAD_UNLOCK(x) apr_thread_mutex_unlock((x)->mutex)
377 #define PROXY_THREAD_LOCK(x) APR_SUCCESS
378 #define PROXY_THREAD_UNLOCK(x) APR_SUCCESS
383 /* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and
384 * PROXY_DECLARE_DATA with appropriate export and import tags for the platform
387 #define PROXY_DECLARE(type) type
388 #define PROXY_DECLARE_NONSTD(type) type
389 #define PROXY_DECLARE_DATA
390 #elif defined(PROXY_DECLARE_STATIC)
391 #define PROXY_DECLARE(type) type __stdcall
392 #define PROXY_DECLARE_NONSTD(type) type
393 #define PROXY_DECLARE_DATA
394 #elif defined(PROXY_DECLARE_EXPORT)
395 #define PROXY_DECLARE(type) __declspec(dllexport) type __stdcall
396 #define PROXY_DECLARE_NONSTD(type) __declspec(dllexport) type
397 #define PROXY_DECLARE_DATA __declspec(dllexport)
399 #define PROXY_DECLARE(type) __declspec(dllimport) type __stdcall
400 #define PROXY_DECLARE_NONSTD(type) __declspec(dllimport) type
401 #define PROXY_DECLARE_DATA __declspec(dllimport)
405 * Hook an optional proxy hook. Unlike static hooks, this uses a macro
406 * instead of a function.
408 #define PROXY_OPTIONAL_HOOK(name,fn,pre,succ,order) \
409 APR_OPTIONAL_HOOK(proxy,name,fn,pre,succ,order)
411 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
412 proxy_worker *worker, proxy_server_conf *conf, char *url,
413 const char *proxyhost, apr_port_t proxyport))
414 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r,
417 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr))
418 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, fixups, (request_rec *r))
422 * It will return the most suitable worker at the moment
423 * and coresponding balancer.
424 * The url is rewritten from balancer://cluster/uri to scheme://host:port/uri
425 * and then the scheme_handler is called.
428 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, pre_request, (proxy_worker **worker,
429 proxy_balancer **balancer,
431 proxy_server_conf *conf, char **url))
434 * It is called after request for updating runtime balancer status.
436 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, post_request, (proxy_worker *worker,
437 proxy_balancer *balancer, request_rec *r,
438 proxy_server_conf *conf))
441 * request status hook
442 * It is called after all proxy processing has been done. This gives other
443 * modules a chance to create default content on failure, for example
445 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, request_status,
446 (int *status, request_rec *r))
450 PROXY_DECLARE(request_rec *)ap_proxy_make_fake_req(conn_rec *c, request_rec *r);
451 PROXY_DECLARE(int) ap_proxy_hex2c(const char *x);
452 PROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x);
453 PROXY_DECLARE(char *)ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t,
454 int forcedec, int proxyreq);
455 PROXY_DECLARE(char *)ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp,
456 char **passwordp, char **hostp, apr_port_t *port);
457 PROXY_DECLARE(const char *)ap_proxy_date_canon(apr_pool_t *p, const char *x);
458 PROXY_DECLARE(int) ap_proxy_liststr(const char *list, const char *val);
459 PROXY_DECLARE(char *)ap_proxy_removestr(apr_pool_t *pool, const char *list, const char *val);
460 PROXY_DECLARE(int) ap_proxy_hex2sec(const char *x);
461 PROXY_DECLARE(void) ap_proxy_sec2hex(int t, char *y);
462 PROXY_DECLARE(int) ap_proxyerror(request_rec *r, int statuscode, const char *message);
463 PROXY_DECLARE(int) ap_proxy_is_ipaddr(struct dirconn_entry *This, apr_pool_t *p);
464 PROXY_DECLARE(int) ap_proxy_is_domainname(struct dirconn_entry *This, apr_pool_t *p);
465 PROXY_DECLARE(int) ap_proxy_is_hostname(struct dirconn_entry *This, apr_pool_t *p);
466 PROXY_DECLARE(int) ap_proxy_is_word(struct dirconn_entry *This, apr_pool_t *p);
467 PROXY_DECLARE(int) ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf, apr_sockaddr_t *uri_addr);
468 PROXY_DECLARE(int) ap_proxy_pre_http_request(conn_rec *c, request_rec *r);
469 PROXY_DECLARE(apr_status_t) ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb, char *buff, size_t bufflen, int *eos);
470 PROXY_DECLARE(void) ap_proxy_table_unmerge(apr_pool_t *p, apr_table_t *t, char *key);
471 /* DEPRECATED (will be replaced with ap_proxy_connect_backend */
472 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 *);
473 PROXY_DECLARE(int) ap_proxy_ssl_enable(conn_rec *c);
474 PROXY_DECLARE(int) ap_proxy_ssl_disable(conn_rec *c);
475 PROXY_DECLARE(int) ap_proxy_conn_is_https(conn_rec *c);
476 PROXY_DECLARE(const char *) ap_proxy_ssl_val(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r, const char *var);
478 /* Header mapping functions, and a typedef of their signature */
479 PROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *url);
480 PROXY_DECLARE(const char *) ap_proxy_cookie_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *str);
483 typedef const char *(*ap_proxy_header_reverse_map_fn)(request_rec *,
484 proxy_dir_conf *, const char *);
485 #elif defined(PROXY_DECLARE_STATIC)
486 typedef const char *(__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
487 proxy_dir_conf *, const char *);
488 #elif defined(PROXY_DECLARE_EXPORT)
489 typedef __declspec(dllexport) const char *
490 (__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
491 proxy_dir_conf *, const char *);
493 typedef __declspec(dllimport) const char *
494 (__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
495 proxy_dir_conf *, const char *);
499 /* Connection pool API */
501 * Get the worker from proxy configuration
502 * @param p memory pool used for finding worker
503 * @param conf current proxy server configuration
504 * @param url url to find the worker from
505 * @return proxy_worker or NULL if not found
507 PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
508 proxy_server_conf *conf,
511 * Add the worker to proxy configuration
512 * @param worker the new worker
513 * @param p memory pool to allocate worker from
514 * @param conf current proxy server configuration
515 * @param url url containing worker name
516 * @return error message or NULL if successfull
518 PROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker,
520 proxy_server_conf *conf,
525 * @param p memory pool to allocate worker from
528 PROXY_DECLARE(proxy_worker *) ap_proxy_create_worker(apr_pool_t *p);
531 * Initize the worker's shared data
532 * @param conf current proxy server configuration
533 * @param worker worker to initialize
534 * @param s current server record
535 * @param worker worker to initialize
537 PROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf,
538 proxy_worker *worker,
544 * @param worker worker to initialize
545 * @param s current server record
546 * @return APR_SUCCESS or error code
548 PROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker,
551 * Get the balancer from proxy configuration
552 * @param p memory pool used for finding balancer
553 * @param conf current proxy server configuration
554 * @param url url to find the worker from. Has to have balancer:// prefix
555 * @return proxy_balancer or NULL if not found
557 PROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
558 proxy_server_conf *conf,
561 * Add the balancer to proxy configuration
562 * @param balancer the new balancer
563 * @param p memory pool to allocate balancer from
564 * @param conf current proxy server configuration
565 * @param url url containing balancer name
566 * @return error message or NULL if successfull
568 PROXY_DECLARE(const char *) ap_proxy_add_balancer(proxy_balancer **balancer,
570 proxy_server_conf *conf,
574 * Add the worker to the balancer
575 * @param pool memory pool for adding worker
576 * @param balancer balancer to add to
577 * @param balancer worker to add
578 * @note Single worker can be added to multiple balancers.
580 PROXY_DECLARE(void) ap_proxy_add_worker_to_balancer(apr_pool_t *pool,
581 proxy_balancer *balancer,
582 proxy_worker *worker);
584 * Get the most suitable worker and(or) balancer for the request
585 * @param worker worker used for processing request
586 * @param balancer balancer used for processing request
587 * @param r current request
588 * @param conf current proxy server configuration
589 * @param url request url that balancer can rewrite.
590 * @return OK or HTTP_XXX error
591 * @note It calls balancer pre_request hook if the url starts with balancer://
592 * The balancer then rewrites the url to particular worker, like http://host:port
594 PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
595 proxy_balancer **balancer,
597 proxy_server_conf *conf,
600 * Post request worker and balancer cleanup
601 * @param worker worker used for processing request
602 * @param balancer balancer used for processing request
603 * @param r current request
604 * @param conf current proxy server configuration
605 * @return OK or HTTP_XXX error
606 * @note When ever the pre_request is called, the post_request has to be
609 PROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker,
610 proxy_balancer *balancer,
612 proxy_server_conf *conf);
615 * Request status function
616 * @param status status of proxy request
617 * @return OK or DECLINED
619 PROXY_DECLARE(int) ap_proxy_request_status(int *status, request_rec *r);
622 * Deternime backend hostname and port
623 * @param p memory pool used for processing
624 * @param r current request
625 * @param conf current proxy server configuration
626 * @param worker worker used for processing request
627 * @param conn proxy connection struct
628 * @param uri processed uri
629 * @param url request url
630 * @param proxyname are we connecting directly or via s proxy
631 * @param proxyport proxy host port
632 * @param server_portstr Via headers server port
633 * @param server_portstr_size size of the server_portstr buffer
634 * @return OK or HTTP_XXX error
636 PROXY_DECLARE(int) ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
637 proxy_server_conf *conf,
638 proxy_worker *worker,
639 proxy_conn_rec *conn,
642 const char *proxyname,
643 apr_port_t proxyport,
644 char *server_portstr,
645 int server_portstr_size);
647 * Mark a worker for retry
648 * @param proxy_function calling proxy scheme (http, ajp, ...)
649 * @param conf current proxy server configuration
650 * @param worker worker used for retrying
651 * @param s current server record
652 * @return OK if marked for retry, DECLINED otherwise
653 * @note Worker will be marker for retry if the time of the last retry
654 * has been ellapsed. In case there is no retry option set, defaults to
655 * number_of_retries seconds.
657 PROXY_DECLARE(int) ap_proxy_retry_worker(const char *proxy_function,
658 proxy_worker *worker,
661 * Acquire a connection from workers connection pool
662 * @param proxy_function calling proxy scheme (http, ajp, ...)
663 * @param conn acquired connection
664 * @param worker worker used for obtaining connection
665 * @param s current server record
666 * @return OK or HTTP_XXX error
667 * @note If the number of connections is exhaused the function will
668 * block untill the timeout is reached.
670 PROXY_DECLARE(int) ap_proxy_acquire_connection(const char *proxy_function,
671 proxy_conn_rec **conn,
672 proxy_worker *worker,
675 * Release a connection back to worker connection pool
676 * @param proxy_function calling proxy scheme (http, ajp, ...)
677 * @param conn acquired connection
678 * @param s current server record
679 * @return OK or HTTP_XXX error
680 * @note The connection will be closed if conn->close_on_release is set
682 PROXY_DECLARE(int) ap_proxy_release_connection(const char *proxy_function,
683 proxy_conn_rec *conn,
686 * Make a connection to the backend
687 * @param proxy_function calling proxy scheme (http, ajp, ...)
688 * @param conn acquired connection
689 * @param worker connection worker
690 * @param s current server record
691 * @return OK or HTTP_XXX error
692 * @note In case the socket already exists for conn, just check the link
695 PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
696 proxy_conn_rec *conn,
697 proxy_worker *worker,
700 * Make a connection record for backend connection
701 * @param proxy_function calling proxy scheme (http, ajp, ...)
702 * @param conn acquired connection
703 * @param c client connection record
704 * @param s current server record
705 * @return OK or HTTP_XXX error
707 PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,
708 proxy_conn_rec *conn,
709 conn_rec *c, server_rec *s);
711 * Signal the upstream chain that the connection to the backend broke in the
712 * middle of the response. This is done by sending an error bucket with
713 * status HTTP_BAD_GATEWAY and an EOS bucket up the filter chain.
714 * @param r current request record of client request
715 * @param brigade The brigade that is sent through the output filter chain
717 PROXY_DECLARE(void) ap_proxy_backend_broke(request_rec *r,
718 apr_bucket_brigade *brigade);
721 #if MODULE_MAGIC_NUMBER_MAJOR > 20020903
722 #define PROXY_HAS_SCOREBOARD 1
724 #define PROXY_HAS_SCOREBOARD 0
727 #define PROXY_LBMETHOD "proxylbmethod"
729 /* The number of dynamic workers that can be added when reconfiguring.
730 * If this limit is reached you must stop and restart the server.
732 #define PROXY_DYNAMIC_BALANCER_LIMIT 16
734 * Calculate number of maximum number of workers in scoreboard.
735 * @return number of workers to allocate in the scoreboard
737 int ap_proxy_lb_workers(void);
740 extern module PROXY_DECLARE_DATA proxy_module;
742 extern int PROXY_DECLARE_DATA proxy_lb_workers;
744 #endif /*MOD_PROXY_H*/