Apache2
mod_proxy.h
Go to the documentation of this file.
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 #ifndef MOD_PROXY_H
18 #define MOD_PROXY_H
19 
29 #include "apr_hooks.h"
30 #include "apr_optional.h"
31 #include "apr.h"
32 #include "apr_lib.h"
33 #include "apr_strings.h"
34 #include "apr_buckets.h"
35 #include "apr_md5.h"
36 #include "apr_network_io.h"
37 #include "apr_pools.h"
38 #include "apr_strings.h"
39 #include "apr_uri.h"
40 #include "apr_date.h"
41 #include "apr_strmatch.h"
42 #include "apr_fnmatch.h"
43 #include "apr_reslist.h"
44 #define APR_WANT_STRFUNC
45 #include "apr_want.h"
46 #include "apr_uuid.h"
47 #include "util_mutex.h"
48 #include "apr_global_mutex.h"
49 #include "apr_thread_mutex.h"
50 
51 #include "httpd.h"
52 #include "http_config.h"
53 #include "ap_config.h"
54 #include "http_core.h"
55 #include "http_protocol.h"
56 #include "http_request.h"
57 #include "http_vhost.h"
58 #include "http_main.h"
59 #include "http_log.h"
60 #include "http_connection.h"
61 #include "http_ssl.h"
62 #include "util_filter.h"
63 #include "util_ebcdic.h"
64 #include "ap_provider.h"
65 #include "ap_slotmem.h"
66 
67 #if APR_HAVE_NETINET_IN_H
68 #include <netinet/in.h>
69 #endif
70 #if APR_HAVE_ARPA_INET_H
71 #include <arpa/inet.h>
72 #endif
73 
74 /* for proxy_canonenc() */
75 enum enctype {
77 };
78 
79 /* Flags for ap_proxy_canonenc_ex */
80 #define PROXY_CANONENC_FORCEDEC 0x01
81 #define PROXY_CANONENC_NOENCODEDSLASHENCODING 0x02
82 
83 typedef enum {
86 
87 typedef struct {
89  char *name;
92 
93 typedef struct {
94  unsigned int bit;
95  char flag;
96  const char *name;
98 
99 #define BALANCER_PREFIX "balancer://"
100 
101 #if APR_CHARSET_EBCDIC
102 #define CRLF "\r\n"
103 #else /*APR_CHARSET_EBCDIC*/
104 #define CRLF "\015\012"
105 #endif /*APR_CHARSET_EBCDIC*/
106 
107 /* default Max-Forwards header setting */
108 /* Set this to -1, which complies with RFC2616 by not setting
109  * max-forwards if the client didn't send it to us.
110  */
111 #define DEFAULT_MAX_FORWARDS -1
112 
113 typedef struct proxy_balancer proxy_balancer;
114 typedef struct proxy_worker proxy_worker;
115 typedef struct proxy_conn_pool proxy_conn_pool;
117 
118 /* static information about a remote proxy */
119 struct proxy_remote {
120  const char *scheme; /* the schemes handled by this proxy, or '*' */
121  const char *protocol; /* the scheme used to talk to this proxy */
122  const char *hostname; /* the hostname of this proxy */
123  ap_regex_t *regexp; /* compiled regex (if any) for the remote */
124  const char *creds; /* auth credentials (if any) for the proxy */
125  int use_regex; /* simple boolean. True if we have a regex pattern */
126  apr_port_t port; /* the port for this proxy */
127 };
128 
129 #define PROXYPASS_NOCANON 0x01
130 #define PROXYPASS_INTERPOLATE 0x02
131 #define PROXYPASS_NOQUERY 0x04
132 #define PROXYPASS_MAP_ENCODED 0x08
133 #define PROXYPASS_MAP_SERVLET 0x18 /* + MAP_ENCODED */
134 struct proxy_alias {
135  const char *real;
136  const char *fake;
138  unsigned int flags;
139  proxy_balancer *balancer; /* only valid for reverse-proxys */
140 };
141 
143  char *name;
144  struct in_addr addr, mask;
146  int (*matcher) (struct dirconn_entry * This, request_rec *r);
147 };
148 
150  const char *name;
152 };
153 
154 typedef struct {
160  apr_array_header_t *workers; /* non-balancer workers, eg ProxyPass http://example.com */
161  apr_array_header_t *balancers; /* list of balancers @ config time */
162  proxy_worker *forward; /* forward proxy worker */
163  proxy_worker *reverse; /* reverse "module-driven" proxy worker */
164  const char *domain; /* domain name to use in absence of a domain name in the request */
165  const char *id;
166  apr_pool_t *pool; /* Pool used for allocating this struct's elements */
167  int req; /* true if proxy requests are enabled */
168  int max_balancers; /* maximum number of allowed balancers */
169  int bgrowth; /* number of post-config balancers can added */
170  enum {
174  via_full
175  } viaopt; /* how to deal with proxy Via: headers */
178  long maxfwd;
180  enum {
183  bad_body
184  } badopt; /* how to deal with bad headers */
185  enum {
188  status_full
189  } proxy_status; /* Status display options */
191  apr_global_mutex_t *mutex; /* global lock - not used */
192  ap_slotmem_instance_t *bslot; /* balancers shm data - runtime */
194 
195  unsigned int req_set:1;
196  unsigned int viaopt_set:1;
197  unsigned int recv_buffer_size_set:1;
198  unsigned int io_buffer_size_set:1;
199  unsigned int maxfwd_set:1;
200  unsigned int timeout_set:1;
201  unsigned int badopt_set:1;
202  unsigned int proxy_status_set:1;
203  unsigned int source_address_set:1;
204  unsigned int bgrowth_set:1;
205  unsigned int bal_persist:1;
206  unsigned int inherit:1;
207  unsigned int inherit_set:1;
208  unsigned int ppinherit:1;
209  unsigned int ppinherit_set:1;
210  unsigned int map_encoded_one:1;
211  unsigned int map_encoded_all:1;
213 
214 typedef struct {
215  const char *p; /* The path */
216  ap_regex_t *r; /* Is this a regex? */
217 
218 /* FIXME
219  * ProxyPassReverse and friends are documented as working inside
220  * <Location>. But in fact they never have done in the case of
221  * more than one <Location>, because the server_conf can't see it.
222  * We need to move them to the per-dir config.
223  * Discussed in February 2005:
224  * http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=110726027118798&w=2
225  */
229  signed char p_is_fnmatch; /* Is the path an fnmatch candidate? */
230  signed char interpolate_env;
232 
241  unsigned int error_override:1;
242  unsigned int preserve_host:1;
243  unsigned int preserve_host_set:1;
244  unsigned int error_override_set:1;
245  unsigned int alias_set:1;
246  unsigned int add_forwarded_headers:1;
248 
251 
252  unsigned int forward_100_continue:1;
253  unsigned int forward_100_continue_set:1;
254 
256 
259  unsigned int async_delay_set:1;
260  unsigned int async_idle_timeout_set:1;
262 
263 /* if we interpolate env vars per-request, we'll need a per-request
264  * copy of the reverse proxy config
265  */
266 typedef struct {
271 
272 struct proxy_address; /* opaque TTL'ed and refcount'ed address */
273 
274 typedef struct {
276  request_rec *r; /* Request record of the backend request
277  * that is used over the backend connection. */
278  proxy_worker *worker; /* Connection pool this connection belongs to */
279  apr_pool_t *pool; /* Subpool for hostname and addr data */
280  const char *hostname;
281  apr_sockaddr_t *addr; /* Preparsed remote address info */
282  apr_pool_t *scpool; /* Subpool used for socket and connection data */
283  apr_socket_t *sock; /* Connection socket */
284  void *data; /* per scheme connection data */
285  void *forward; /* opaque forward proxy data */
286  apr_uint32_t flags; /* Connection flags */
288  unsigned int is_ssl:1;
289  unsigned int close:1; /* Close 'this' connection */
290  unsigned int need_flush:1; /* Flag to decide whether we need to flush the
291  * filter chain or not */
292  unsigned int inreslist:1; /* connection in apr_reslist? */
293  const char *uds_path; /* Unix domain socket path */
294  const char *ssl_hostname;/* Hostname (SNI) in use by SSL connection */
295  apr_bucket_brigade *tmp_bb;/* Temporary brigade created with the connection
296  * and its scpool/bucket_alloc (NULL before),
297  * must be left cleaned when used (locally).
298  */
299  apr_pool_t *uds_pool; /* Subpool for reusing UDS paths */
300  apr_pool_t *fwd_pool; /* Subpool for reusing ProxyRemote infos */
301  struct proxy_address *address; /* Current remote address */
303 
304 typedef struct {
305  float cache_completion; /* completion percentage */
306  int content_length; /* length of the content */
308 
309 /* Connection pool */
311  apr_pool_t *pool; /* The pool used in constructor and destructor calls */
312  apr_sockaddr_t *addr; /* Preparsed remote address info */
313  apr_reslist_t *res; /* Connection resource list */
314  proxy_conn_rec *conn; /* Single connection for prefork mpm */
315  apr_pool_t *dns_pool; /* The pool used for worker scoped DNS resolutions */
316 };
317 
318 #define AP_VOLATILIZE_T(T, x) (*(T volatile *)&(x))
319 
320 /* worker status bits */
321 /*
322  * NOTE: Keep up-to-date w/ proxy_wstat_tbl[]
323  * in mod_proxy.c !
324  */
325 #define PROXY_WORKER_INITIALIZED 0x0001
326 #define PROXY_WORKER_IGNORE_ERRORS 0x0002
327 #define PROXY_WORKER_DRAIN 0x0004
328 #define PROXY_WORKER_GENERIC 0x0008
329 #define PROXY_WORKER_IN_SHUTDOWN 0x0010
330 #define PROXY_WORKER_DISABLED 0x0020
331 #define PROXY_WORKER_STOPPED 0x0040
332 #define PROXY_WORKER_IN_ERROR 0x0080
333 #define PROXY_WORKER_HOT_STANDBY 0x0100
334 #define PROXY_WORKER_FREE 0x0200
335 #define PROXY_WORKER_HC_FAIL 0x0400
336 #define PROXY_WORKER_HOT_SPARE 0x0800
337 
338 /* worker status flags */
339 #define PROXY_WORKER_INITIALIZED_FLAG 'O'
340 #define PROXY_WORKER_IGNORE_ERRORS_FLAG 'I'
341 #define PROXY_WORKER_DRAIN_FLAG 'N'
342 #define PROXY_WORKER_GENERIC_FLAG 'G'
343 #define PROXY_WORKER_IN_SHUTDOWN_FLAG 'U'
344 #define PROXY_WORKER_DISABLED_FLAG 'D'
345 #define PROXY_WORKER_STOPPED_FLAG 'S'
346 #define PROXY_WORKER_IN_ERROR_FLAG 'E'
347 #define PROXY_WORKER_HOT_STANDBY_FLAG 'H'
348 #define PROXY_WORKER_FREE_FLAG 'F'
349 #define PROXY_WORKER_HC_FAIL_FLAG 'C'
350 #define PROXY_WORKER_HOT_SPARE_FLAG 'R'
351 
352 #define PROXY_WORKER_NOT_USABLE_BITMAP ( PROXY_WORKER_IN_SHUTDOWN | \
353 PROXY_WORKER_DISABLED | PROXY_WORKER_STOPPED | PROXY_WORKER_IN_ERROR | \
354 PROXY_WORKER_HC_FAIL )
355 
356 /* NOTE: these check the shared status */
357 #define PROXY_WORKER_IS_INITIALIZED(f) ( (f)->s->status & PROXY_WORKER_INITIALIZED )
358 
359 #define PROXY_WORKER_IS_STANDBY(f) ( (f)->s->status & PROXY_WORKER_HOT_STANDBY )
360 
361 #define PROXY_WORKER_IS_SPARE(f) ( (f)->s->status & PROXY_WORKER_HOT_SPARE )
362 
363 #define PROXY_WORKER_IS_USABLE(f) ( ( !( (f)->s->status & PROXY_WORKER_NOT_USABLE_BITMAP) ) && \
364  PROXY_WORKER_IS_INITIALIZED(f) )
365 
366 #define PROXY_WORKER_IS_DRAINING(f) ( (f)->s->status & PROXY_WORKER_DRAIN )
367 
368 #define PROXY_WORKER_IS_GENERIC(f) ( (f)->s->status & PROXY_WORKER_GENERIC )
369 
370 #define PROXY_WORKER_IS_HCFAILED(f) ( (f)->s->status & PROXY_WORKER_HC_FAIL )
371 
372 #define PROXY_WORKER_IS_ERROR(f) ( (f)->s->status & PROXY_WORKER_IN_ERROR )
373 
374 #define PROXY_WORKER_IS(f, b) ( (f)->s->status & (b) )
375 
376 /* default worker retry timeout in seconds */
377 #define PROXY_WORKER_DEFAULT_RETRY 60
378 
379 /* Some max char string sizes, for shm fields */
380 #define PROXY_WORKER_MAX_SCHEME_SIZE 16
381 #define PROXY_WORKER_MAX_ROUTE_SIZE 96
382 #define PROXY_BALANCER_MAX_ROUTE_SIZE 64
383 #define PROXY_WORKER_MAX_NAME_SIZE 384
384 #define PROXY_BALANCER_MAX_NAME_SIZE 64
385 #define PROXY_WORKER_MAX_HOSTNAME_SIZE 96
386 #define PROXY_BALANCER_MAX_HOSTNAME_SIZE 64
387 #define PROXY_BALANCER_MAX_STICKY_SIZE 64
388 #define PROXY_WORKER_MAX_SECRET_SIZE 64
389 #define PROXY_WORKER_UDS_PATH_SIZE 256
390 
391 #define PROXY_RFC1035_HOSTNAME_SIZE 256
392 
393 /* RFC-1035 mentions limits of 255 for host-names and 253 for domain-names,
394  * dotted together(?) this would fit the below size (+ trailing NUL).
395  */
396 #define PROXY_WORKER_RFC1035_NAME_SIZE 512
397 
398 #define PROXY_MAX_PROVIDER_NAME_SIZE 16
399 
400 #define PROXY_STRNCPY(dst, src) ap_proxy_strncpy((dst), (src), (sizeof(dst)))
401 
402 #define PROXY_COPY_CONF_PARAMS(w, c) \
403 do { \
404 (w)->s->timeout = (c)->timeout; \
405 (w)->s->timeout_set = (c)->timeout_set; \
406 (w)->s->recv_buffer_size = (c)->recv_buffer_size; \
407 (w)->s->recv_buffer_size_set = (c)->recv_buffer_size_set; \
408 (w)->s->io_buffer_size = (c)->io_buffer_size; \
409 (w)->s->io_buffer_size_set = (c)->io_buffer_size_set; \
410 } while (0)
411 
412 #define PROXY_SHOULD_PING_100_CONTINUE(w, r) \
413  ((w)->s->ping_timeout_set \
414  && (PROXYREQ_REVERSE == (r)->proxyreq) \
415  && ap_request_has_body((r)))
416 
417 #define PROXY_DO_100_CONTINUE(w, r) \
418  (PROXY_SHOULD_PING_100_CONTINUE(w, r) \
419  && !apr_table_get((r)->subprocess_env, "force-proxy-request-1.0"))
420 
421 /* use 2 hashes */
422 typedef struct {
423  unsigned int def;
424  unsigned int fnv;
425 } proxy_hashes ;
426 
427 /* Runtime worker status information. Shared in scoreboard */
428 typedef struct {
430  char scheme[PROXY_WORKER_MAX_SCHEME_SIZE]; /* scheme to use ajp|http|https */
431  char hostname[PROXY_WORKER_MAX_HOSTNAME_SIZE]; /* remote backend address (deprecated, use hostname_ex below) */
432  char route[PROXY_WORKER_MAX_ROUTE_SIZE]; /* balancing route */
433  char redirect[PROXY_WORKER_MAX_ROUTE_SIZE]; /* temporary balancing redirection route */
434  char flusher[PROXY_WORKER_MAX_SCHEME_SIZE]; /* flush provider used by mod_proxy_fdpass */
435  char uds_path[PROXY_WORKER_UDS_PATH_SIZE]; /* path to worker's unix domain socket if applicable */
436  char hcuri[PROXY_WORKER_MAX_ROUTE_SIZE]; /* health check uri */
437  char hcexpr[PROXY_WORKER_MAX_SCHEME_SIZE]; /* name of condition expr for health check */
438  char secret[PROXY_WORKER_MAX_SECRET_SIZE]; /* authentication secret (e.g. AJP13) */
439  char upgrade[PROXY_WORKER_MAX_SCHEME_SIZE];/* upgrade protocol used by mod_proxy_wstunnel */
440  char hostname_ex[PROXY_RFC1035_HOSTNAME_SIZE]; /* RFC1035 compliant version of the remote backend address */
441  int lbset; /* load balancer cluster set */
442  int retries; /* number of retries on this worker */
443  int lbstatus; /* Current lbstatus */
444  int lbfactor; /* dynamic lbfactor */
445  int min; /* Desired minimum number of available connections */
446  int smax; /* Soft maximum on the total number of connections */
447  int hmax; /* Hard maximum on the total number of connections */
448  int flush_wait; /* poll wait time in microseconds if flush_auto */
449  int index; /* shm array index */
450  int passes; /* number of successes for check to pass */
451  int pcount; /* current count of passes */
452  int fails; /* number of failures for check to fail */
453  int fcount; /* current count of failures */
454  proxy_hashes hash; /* hash of worker name */
455  unsigned int status; /* worker status bitfield */
456  enum {
459  flush_auto
460  } flush_packets; /* control AJP flushing */
461  hcmethod_t method; /* method to use for health check */
462  apr_time_t updated; /* timestamp of last update for dynamic workers, or queue-time of HC workers */
463  apr_time_t error_time; /* time of the last error */
464  apr_interval_time_t ttl; /* maximum amount of time in seconds a connection
465  * may be available while exceeding the soft limit */
466  apr_interval_time_t retry; /* retry interval */
467  apr_interval_time_t timeout; /* connection timeout */
468  apr_interval_time_t acquire; /* acquire timeout when the maximum number of connections is exceeded */
474  apr_size_t elected; /* Number of times the worker was elected */
475  apr_size_t busy; /* busyness factor */
476  apr_size_t response_field_size; /* Size of proxy response buffer in bytes. */
478  apr_off_t transferred;/* Number of bytes transferred to remote */
479  apr_off_t read; /* Number of bytes read from remote */
480  void *context; /* general purpose storage */
481  unsigned int keepalive:1;
482  unsigned int disablereuse:1;
483  unsigned int is_address_reusable:1;
484  unsigned int retry_set:1;
485  unsigned int timeout_set:1;
486  unsigned int acquire_set:1;
487  unsigned int ping_timeout_set:1;
488  unsigned int conn_timeout_set:1;
489  unsigned int recv_buffer_size_set:1;
490  unsigned int io_buffer_size_set:1;
491  unsigned int keepalive_set:1;
492  unsigned int disablereuse_set:1;
493  unsigned int was_malloced:1;
494  unsigned int is_name_matchable:1;
495  unsigned int response_field_size_set:1;
496  unsigned int address_ttl_set:1;
497  apr_int32_t address_ttl; /* backend address' TTL (seconds) */
498  apr_uint32_t address_expiry; /* backend address' next expiry time */
500 
501 #define ALIGNED_PROXY_WORKER_SHARED_SIZE (APR_ALIGN_DEFAULT(sizeof(proxy_worker_shared)))
502 
503 /* Worker configuration */
504 struct proxy_worker {
505  proxy_hashes hash; /* hash of worker name */
506  unsigned int local_status; /* status of per-process worker */
507  proxy_conn_pool *cp; /* Connection pool to use */
508  proxy_worker_shared *s; /* Shared data */
509  proxy_balancer *balancer; /* which balancer am I in? */
510 #if APR_HAS_THREADS
511  apr_thread_mutex_t *tmutex; /* Thread lock for updating address cache */
512 #endif
513  void *context; /* general purpose storage */
514  ap_conf_vector_t *section_config; /* <Proxy>-section wherein defined */
515  struct proxy_address *volatile address; /* current worker address (if reusable) */
516  const char *uds_name; /* "unix:/uds/path|worker-URL" */
517 };
518 
519 /* default to health check every 30 seconds */
520 #define HCHECK_WATHCHDOG_DEFAULT_INTERVAL (30)
521 
522 /*
523  * Time to wait (in microseconds) to find out if more data is currently
524  * available at the backend.
525  */
526 #define PROXY_FLUSH_WAIT 10000
527 
528 typedef struct {
529  char sticky_path[PROXY_BALANCER_MAX_STICKY_SIZE]; /* URL sticky session identifier */
530  char sticky[PROXY_BALANCER_MAX_STICKY_SIZE]; /* sticky session identifier */
531  char lbpname[PROXY_MAX_PROVIDER_NAME_SIZE]; /* lbmethod provider name */
532  char nonce[APR_UUID_FORMATTED_LENGTH + 1];
537  apr_interval_time_t timeout; /* Timeout for waiting on free connection */
538  apr_time_t wupdated; /* timestamp of last change to workers list */
539  int max_attempts; /* Number of attempts before failing */
540  int index; /* shm array index */
542  unsigned int sticky_force:1; /* Disable failover for sticky sessions */
543  unsigned int scolonsep:1; /* true if ';' seps sticky session paths */
544  unsigned int max_attempts_set:1;
545  unsigned int was_malloced:1;
546  unsigned int need_reset:1;
547  unsigned int vhosted:1;
548  unsigned int inactive:1;
549  unsigned int forcerecovery:1;
550  char sticky_separator; /* separator for sessionid/route */
551  unsigned int forcerecovery_set:1;
552  unsigned int scolonsep_set:1;
553  unsigned int sticky_force_set:1;
554  unsigned int nonce_set:1;
555  unsigned int sticky_separator_set:1;
557 
558 #define ALIGNED_PROXY_BALANCER_SHARED_SIZE (APR_ALIGN_DEFAULT(sizeof(proxy_balancer_shared)))
559 
561  apr_array_header_t *workers; /* initially configured workers */
562  apr_array_header_t *errstatuses; /* statuses to force members into error */
563  ap_slotmem_instance_t *wslot; /* worker shm data - runtime */
565  int growth; /* number of post-config workers can added */
566  int max_workers; /* maximum number of allowed workers */
568  apr_time_t wupdated; /* timestamp of last change to workers list */
570  apr_global_mutex_t *gmutex; /* global lock for updating list of workers */
571 #if APR_HAS_THREADS
572  apr_thread_mutex_t *tmutex; /* Thread lock for updating shm */
573 #endif
575  void *context; /* general purpose storage */
576  proxy_balancer_shared *s; /* Shared data */
577  int failontimeout; /* Whether to mark a member in Err if IO timeout occurs */
578  unsigned int failontimeout_set:1;
579  unsigned int growth_set:1;
580  unsigned int lbmethod_set:1;
581  ap_conf_vector_t *section_config; /* <Proxy>-section wherein defined */
582 };
583 
585  const char *name; /* name of the load balancer method*/
586  proxy_worker *(*finder)(proxy_balancer *balancer,
587  request_rec *r);
588  void *context; /* general purpose storage */
592 };
593 
594 #if APR_HAS_THREADS
595 #define PROXY_THREAD_LOCK(x) ( (x) && (x)->tmutex ? apr_thread_mutex_lock((x)->tmutex) : APR_SUCCESS)
596 #define PROXY_THREAD_UNLOCK(x) ( (x) && (x)->tmutex ? apr_thread_mutex_unlock((x)->tmutex) : APR_SUCCESS)
597 #else
598 #define PROXY_THREAD_LOCK(x) (APR_SUCCESS)
599 #define PROXY_THREAD_UNLOCK(x) (APR_SUCCESS)
600 #endif
601 
602 #define PROXY_GLOBAL_LOCK(x) ( (x) && (x)->gmutex ? apr_global_mutex_lock((x)->gmutex) : APR_SUCCESS)
603 #define PROXY_GLOBAL_UNLOCK(x) ( (x) && (x)->gmutex ? apr_global_mutex_unlock((x)->gmutex) : APR_SUCCESS)
604 
605 /* hooks */
606 
607 /* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and
608  * PROXY_DECLARE_DATA with appropriate export and import tags for the platform
609  */
610 #if !defined(WIN32)
611 #define PROXY_DECLARE(type) type
612 #define PROXY_DECLARE_NONSTD(type) type
613 #define PROXY_DECLARE_DATA
614 #elif defined(PROXY_DECLARE_STATIC)
615 #define PROXY_DECLARE(type) type __stdcall
616 #define PROXY_DECLARE_NONSTD(type) type
617 #define PROXY_DECLARE_DATA
618 #elif defined(PROXY_DECLARE_EXPORT)
619 #define PROXY_DECLARE(type) __declspec(dllexport) type __stdcall
620 #define PROXY_DECLARE_NONSTD(type) __declspec(dllexport) type
621 #define PROXY_DECLARE_DATA __declspec(dllexport)
622 #else
623 #define PROXY_DECLARE(type) __declspec(dllimport) type __stdcall
624 #define PROXY_DECLARE_NONSTD(type) __declspec(dllimport) type
625 #define PROXY_DECLARE_DATA __declspec(dllimport)
626 #endif
627 
628 /* Using PROXY_DECLARE_OPTIONAL_HOOK instead of
629  * APR_DECLARE_EXTERNAL_HOOK allows build/make_nw_export.awk
630  * to distinguish between hooks that implement
631  * proxy_hook_xx and proxy_hook_get_xx in mod_proxy.c and
632  * those which don't.
633  */
634 #define PROXY_DECLARE_OPTIONAL_HOOK APR_DECLARE_EXTERNAL_HOOK
635 
636 
637 /* These 2 are in mod_proxy.c */
640 
641 /* Following 4 from health check */
647  const char *, const char *, void *));
648 
649 PROXY_DECLARE_OPTIONAL_HOOK(proxy, PROXY, int, section_post_config,
650  (apr_pool_t *p, apr_pool_t *plog,
651  apr_pool_t *ptemp, server_rec *s,
652  ap_conf_vector_t *section_config))
653 
654 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler,
656  proxy_server_conf *conf, char *url,
658 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, check_trans,
659  (request_rec *r, const char *url))
660 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler,
661  (request_rec *r, char *url))
662 
663 PROXY_DECLARE_OPTIONAL_HOOK(proxy, PROXY, int, create_req,
664  (request_rec *r, request_rec *pr))
666 
667 
676 
685 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, pre_request,
686  (proxy_worker **worker, proxy_balancer **balancer,
692 APR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, post_request,
693  (proxy_worker *worker, proxy_balancer *balancer,
695 
701 PROXY_DECLARE_OPTIONAL_HOOK(proxy, PROXY, int, request_status,
702  (int *status, request_rec *r))
703 
704 /* proxy_util.c */
705 
706 PROXY_DECLARE(apr_status_t) ap_proxy_strncpy(char *dst, const char *src,
708 PROXY_DECLARE(int) ap_proxy_hex2c(const char *x);
709 PROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x);
710 PROXY_DECLARE(char *)ap_proxy_canonenc_ex(apr_pool_t *p, const char *x, int len, enum enctype t,
711  int flags, int proxyreq);
712 PROXY_DECLARE(char *)ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t,
713  int forcedec, int proxyreq);
714 PROXY_DECLARE(char *)ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp,
715  char **passwordp, char **hostp, apr_port_t *port);
716 PROXY_DECLARE(int) ap_proxyerror(request_rec *r, int statuscode, const char *message);
717 
727  const char *hostname, apr_sockaddr_t *addr);
728 
729 
731 /* DEPRECATED (will be replaced with ap_proxy_connect_backend */
733 /* DEPRECATED (will be replaced with ap_proxy_check_connection */
735  request_rec *r);
739  ap_conf_vector_t *per_dir_config,
740  int enable);
742 PROXY_DECLARE(const char *) ap_proxy_ssl_val(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r, const char *var);
743 
744 /* Header mapping functions, and a typedef of their signature */
747 
748 #if !defined(WIN32)
749 typedef const char *(*ap_proxy_header_reverse_map_fn)(request_rec *,
750  proxy_dir_conf *, const char *);
751 #elif defined(PROXY_DECLARE_STATIC)
752 typedef const char *(__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
753  proxy_dir_conf *, const char *);
754 #elif defined(PROXY_DECLARE_EXPORT)
755 typedef __declspec(dllexport) const char *
757  proxy_dir_conf *, const char *);
758 #else
759 typedef __declspec(dllimport) const char *
761  proxy_dir_conf *, const char *);
762 #endif
763 
764 
765 /* Connection pool API */
777 
784 
794  const proxy_worker *worker,
795  const char *upgrade,
796  const char *dflt);
797 
798 /* Bitmask for ap_proxy_{define,get}_worker_ex(). */
799 #define AP_PROXY_WORKER_IS_PREFIX (1u << 0)
800 #define AP_PROXY_WORKER_IS_MATCH (1u << 1)
801 #define AP_PROXY_WORKER_IS_MALLOCED (1u << 2)
802 #define AP_PROXY_WORKER_NO_UDS (1u << 3)
803 
815  proxy_balancer *balancer,
817  const char *url,
818  unsigned int mask);
819 
829  proxy_balancer *balancer,
831  const char *url);
832 
846  proxy_balancer *balancer,
848  const char *url,
849  unsigned int mask);
850 
863  proxy_balancer *balancer,
865  const char *url,
866  int do_malloc);
867 
882  proxy_balancer *balancer,
884  const char *url,
885  int do_malloc);
886 
895  proxy_worker_shared *shm,
896  int i);
897 
906  server_rec *s,
907  apr_pool_t *p);
908 
916 
917 
928  const char *url,
929  int careactive);
930 
939  proxy_balancer *balancer,
940  const char *url);
941 
953  proxy_balancer **balancer,
955  const char *url,
956  const char *alias,
957  int do_malloc);
958 
968  int i);
969 
978  server_rec *s,
979  apr_pool_t *p);
980 
981 typedef int (proxy_is_best_callback_fn_t)(proxy_worker *current, proxy_worker *prev_best, void *baton);
982 
994  request_rec *r,
996  void *baton);
997 /*
998  * Needed by the lb modules.
999  */
1001  (proxy_balancer *balancer,
1002  request_rec *r,
1003  proxy_is_best_callback_fn_t *is_best,
1004  void *baton));
1005 
1015  ap_slotmem_instance_t *slot,
1017  unsigned int *index);
1018 
1028  ap_slotmem_instance_t *slot,
1029  proxy_balancer *balancer,
1030  unsigned int *index);
1031 
1044  proxy_balancer **balancer,
1045  request_rec *r,
1047  char **url);
1059  proxy_balancer *balancer,
1060  request_rec *r,
1062 
1063 /* Bitmask for ap_proxy_determine_address() */
1064 #define PROXY_DETERMINE_ADDRESS_CHECK (1u << 0)
1079  proxy_conn_rec *conn,
1080  const char *hostname,
1081  apr_port_t hostport,
1082  unsigned int flags,
1083  request_rec *r,
1084  server_rec *s);
1085 
1105  proxy_conn_rec *conn,
1106  apr_uri_t *uri,
1107  char **url,
1108  const char *proxyname,
1110  char *server_portstr,
1111  int server_portstr_size);
1112 
1123  (const char *proxy_function, proxy_worker *worker, server_rec *s));
1124 
1136 PROXY_DECLARE(int) ap_proxy_acquire_connection(const char *proxy_function,
1137  proxy_conn_rec **conn,
1139  server_rec *s);
1148 PROXY_DECLARE(int) ap_proxy_release_connection(const char *proxy_function,
1149  proxy_conn_rec *conn,
1150  server_rec *s);
1151 
1152 #define PROXY_CHECK_CONN_EMPTY (1 << 0)
1168  proxy_conn_rec *conn,
1169  server_rec *server,
1170  unsigned max_blank_lines,
1171  int flags);
1172 
1183 PROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
1184  proxy_conn_rec *conn,
1186  server_rec *s);
1187 
1196  const char *uds_path,
1197  apr_pool_t *p);
1208 PROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,
1209  proxy_conn_rec *conn,
1210  conn_rec *c, server_rec *s);
1211 
1221 PROXY_DECLARE(int) ap_proxy_connection_create_ex(const char *proxy_function,
1222  proxy_conn_rec *conn,
1223  request_rec *r);
1233 
1247  int eoc);
1248 
1258  apr_bucket_brigade *brigade);
1259 
1268 
1269 PROXY_DECLARE(unsigned int) ap_proxy_hashfunc(const char *str, proxy_hash_t method);
1270 
1271 
1280 
1281 
1289 
1290 
1299  server_rec *s,
1301 
1302 
1315  struct proxy_alias *ent,
1316  proxy_dir_conf *dconf);
1317 
1334  apr_bucket_brigade *header_brigade,
1335  request_rec *r,
1336  proxy_conn_rec *p_conn,
1339  apr_uri_t *uri,
1340  char *url, char *server_portstr,
1341  char **old_cl_val,
1342  char **old_te_val);
1343 
1358  proxy_conn_rec *backend,
1359  apr_bucket_brigade *input_brigade,
1361  apr_off_t *bytes_read,
1362  apr_off_t max_read);
1363 
1374  proxy_conn_rec *backend,
1375  apr_bucket_brigade *input_brigade,
1376  apr_off_t *bytes_spooled,
1377  apr_off_t max_mem_spool);
1378 
1389  proxy_conn_rec *backend,
1390  apr_bucket_brigade *input_brigade,
1391  apr_off_t max_read);
1392 
1403  request_rec *r, proxy_conn_rec *p_conn,
1404  conn_rec *origin, apr_bucket_brigade *bb,
1405  int flush);
1406 
1407 struct proxy_tunnel_conn; /* opaque */
1408 typedef struct proxy_tunnel_conn proxy_tunnel_conn_t;
1409 typedef struct {
1411  const char *scheme;
1418  int replied; /* TODO 2.5+: one bit to merge in below bitmask */
1419  unsigned int nohalfclose :1;
1421 
1431  request_rec *r, conn_rec *c_o,
1432  const char *scheme);
1433 
1442 
1443 /*
1444  * Number of incoming bytes on the tunnel connection.
1445  * @param tc tunnel connection
1446  * @return number of bytes.
1447  */
1449  const proxy_tunnel_conn_t *tc);
1450 /*
1451  * Number of outgoing bytes on the tunnel connection.
1452  * @param tc tunnel connection
1453  * @return number of bytes.
1454  */
1456  const proxy_tunnel_conn_t *tc);
1457 
1471 PROXY_DECLARE_OPTIONAL_HOOK(proxy, PROXY, int, tunnel_forward,
1472  (proxy_tunnel_rec *tunnel,
1473  conn_rec *c_i, conn_rec *c_o,
1475 
1476 
1483 APR_DECLARE_OPTIONAL_FN(int, ap_proxy_clear_connection,
1485 
1495  (request_rec *, apr_table_t *params));
1496 
1502  (apr_socket_t *sock, request_rec *r,
1504 
1505 
1511 
1512 #define PROXY_LBMETHOD "proxylbmethod"
1513 
1514 /* The number of dynamic workers that can be added when reconfiguring.
1515  * If this limit is reached you must stop and restart the server.
1516  */
1517 #define PROXY_DYNAMIC_BALANCER_LIMIT 16
1518 
1524 
1533 
1540 
1547 
1554 PROXY_DECLARE(const char *) ap_proxy_de_socketfy(apr_pool_t *p, const char *url);
1555 
1556 /*
1557  * Transform buckets from one bucket allocator to another one by creating a
1558  * transient bucket for each data bucket and let it use the data read from
1559  * the old bucket. Metabuckets are transformed by just recreating them.
1560  * Attention: Currently only the following bucket types are handled:
1561  *
1562  * All data buckets
1563  * FLUSH
1564  * EOS
1565  *
1566  * If an other bucket type is found its type is logged as a debug message
1567  * and APR_EGENERAL is returned.
1568  *
1569  * @param r request_rec of the actual request. Used for logging purposes
1570  * @param from the bucket brigade to take the buckets from
1571  * @param to the bucket brigade to store the transformed buckets
1572  * @return apr_status_t of the operation. Either APR_SUCCESS or
1573  * APR_EGENERAL
1574  */
1576  apr_bucket_brigade *from,
1577  apr_bucket_brigade *to);
1578 
1579 /*
1580  * The flags for ap_proxy_transfer_between_connections(), where for legacy and
1581  * compatibility reasons FLUSH_EACH and FLUSH_AFTER are boolean values.
1582  */
1583 #define AP_PROXY_TRANSFER_FLUSH_EACH (0x00)
1584 #define AP_PROXY_TRANSFER_FLUSH_AFTER (0x01)
1585 #define AP_PROXY_TRANSFER_YIELD_PENDING (0x02)
1586 #define AP_PROXY_TRANSFER_YIELD_MAX_READS (0x04)
1587 
1588 /*
1589  * Sends all data that can be read non blocking from the input filter chain of
1590  * c_i and send it down the output filter chain of c_o. For reading it uses
1591  * the bucket brigade bb_i which should be created from the bucket allocator
1592  * associated with c_i. For sending through the output filter chain it uses
1593  * the bucket brigade bb_o which should be created from the bucket allocator
1594  * associated with c_o. In order to get the buckets from bb_i to bb_o
1595  * ap_proxy_buckets_lifetime_transform is used.
1596  *
1597  * @param r request_rec of the actual request. Used for logging purposes
1598  * @param c_i inbound connection conn_rec
1599  * @param c_o outbound connection conn_rec
1600  * @param bb_i bucket brigade for pulling data from the inbound connection
1601  * @param bb_o bucket brigade for sending data through the outbound connection
1602  * @param name string for logging from where data was pulled
1603  * @param sent if not NULL will be set to 1 if data was sent through c_o
1604  * @param bsize maximum amount of data pulled in one iteration from c_i
1605  * @param flags AP_PROXY_TRANSFER_* bitmask
1606  * @return apr_status_t of the operation. Could be any error returned from
1607  * either the input filter chain of c_i or the output filter chain
1608  * of c_o, APR_EPIPE if the outgoing connection was aborted, or
1609  * APR_INCOMPLETE if AP_PROXY_TRANSFER_YIELD_PENDING was set and
1610  * the output stack gets full before the input stack is exhausted.
1611  */
1613  request_rec *r,
1614  conn_rec *c_i,
1615  conn_rec *c_o,
1616  apr_bucket_brigade *bb_i,
1617  apr_bucket_brigade *bb_o,
1618  const char *name,
1619  int *sent,
1620  apr_off_t bsize,
1621  int flags);
1622 
1624 
1625 #endif /*MOD_PROXY_H*/
Symbol export macros and hook functions.
Apache Provider API.
Memory Slot Extension Storage Module for Apache.
APR Platform Definitions.
#define socket
Definition: apr_arch_os2calls.h:41
APR-UTIL Buckets/Bucket Brigades.
APR-UTIL date routines.
APR FNMatch Functions.
APR Global Locking Routines.
Apache hook functions.
APR general purpose library routines.
APR MD5 Routines.
APR Network library.
APR-UTIL registration of functions exported by modules.
APR memory allocation.
APR-UTIL Resource List Routines.
APR Strings library.
APR-UTIL string matching routines.
APR Thread Mutex Routines.
APR-UTIL URI Routines.
APR UUID library.
APR Standard Headers Support.
struct ap_conf_vector_t ap_conf_vector_t
Definition: http_config.h:512
#define APR_UUID_FORMATTED_LENGTH
Definition: apr_uuid.h:46
apr_read_type_e
Definition: apr_buckets.h:62
struct apr_bucket_alloc_t apr_bucket_alloc_t
Definition: apr_buckets.h:128
#define APR_DECLARE_EXTERNAL_HOOK(ns, link, ret, name, args)
Definition: apr_hooks.h:118
#define APR_DECLARE_OPTIONAL_FN(ret, name, args)
Definition: apr_optional.h:50
struct apr_reslist_t apr_reslist_t
Definition: apr_reslist.h:42
struct ap_slotmem_instance_t ap_slotmem_instance_t
Definition: ap_slotmem.h:75
dav_resource int dav_locktoken dav_response int flags
Definition: mod_dav.h:1458
dav_buffer const char * str
Definition: mod_dav.h:465
int status
Definition: mod_dav.h:141
apr_bucket_brigade * bb
Definition: mod_dav.h:555
const char * s
Definition: mod_dav.h:1327
const char const char * uri
Definition: mod_dav.h:631
const char * name
Definition: mod_dav.h:805
apr_bucket_brigade ap_input_mode_t apr_read_type_e block
Definition: mod_dav.h:2663
char * ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp, char **passwordp, char **hostp, apr_port_t *port)
const char * ap_proxy_ssl_val(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r, const char *var)
#define PROXY_DECLARE_DATA
Definition: mod_proxy.h:613
char * ap_proxy_define_worker_ex(apr_pool_t *p, proxy_worker **worker, proxy_balancer *balancer, proxy_server_conf *conf, const char *url, unsigned int mask)
apr_table_t * headers
Definition: mod_proxy.h:1484
int ap_proxy_ssl_engine(conn_rec *c, ap_conf_vector_t *per_dir_config, int enable)
char * ap_proxy_parse_wstatus(apr_pool_t *p, proxy_worker *w)
proxy_worker proxy_server_conf char const char apr_port_t proxyport
Definition: mod_proxy.h:657
PROXY_DECLARE_DATA proxy_wstat_t proxy_wstat_tbl[]
int ap_proxy_connect_backend(const char *proxy_function, proxy_conn_rec *conn, proxy_worker *worker, server_rec *s)
#define PROXY_WORKER_MAX_HOSTNAME_SIZE
Definition: mod_proxy.h:385
struct proxy_tunnel_conn proxy_tunnel_conn_t
Definition: mod_proxy.h:1408
#define PROXY_BALANCER_MAX_NAME_SIZE
Definition: mod_proxy.h:384
apr_status_t ap_proxy_transfer_between_connections(request_rec *r, conn_rec *c_i, conn_rec *c_o, apr_bucket_brigade *bb_i, apr_bucket_brigade *bb_o, const char *name, int *sent, apr_off_t bsize, int flags)
proxy_worker proxy_server_conf char const char * proxyhost
Definition: mod_proxy.h:657
proxy_balancer * ap_proxy_get_balancer(apr_pool_t *p, proxy_server_conf *conf, const char *url, int careactive)
int ap_proxy_ssl_disable(conn_rec *c)
char * ap_proxy_worker_name(apr_pool_t *unused, proxy_worker *worker)
apr_status_t ap_proxy_set_wstatus(char c, int set, proxy_worker *w)
int ap_proxy_should_override(proxy_dir_conf *conf, int code)
#define PROXY_WORKER_MAX_ROUTE_SIZE
Definition: mod_proxy.h:381
module PROXY_DECLARE_DATA proxy_module
#define PROXY_DECLARE(type)
Definition: mod_proxy.h:611
#define PROXY_BALANCER_MAX_ROUTE_SIZE
Definition: mod_proxy.h:382
int ap_proxy_read_input(request_rec *r, proxy_conn_rec *backend, apr_bucket_brigade *input_brigade, apr_off_t max_read)
PROXY
Definition: mod_proxy.h:674
int ap_proxy_release_connection(const char *proxy_function, proxy_conn_rec *conn, server_rec *s)
int ap_proxy_tunnel_run(proxy_tunnel_rec *tunnel)
const char * ap_proxy_show_hcmethod(hcmethod_t method)
char * ap_proxy_update_balancer(apr_pool_t *p, proxy_balancer *balancer, const char *url)
int ap_proxy_acquire_connection(const char *proxy_function, proxy_conn_rec **conn, proxy_worker *worker, server_rec *s)
#define PROXY_WORKER_UDS_PATH_SIZE
Definition: mod_proxy.h:389
apr_status_t ap_proxy_determine_address(const char *proxy_function, proxy_conn_rec *conn, const char *hostname, apr_port_t hostport, unsigned int flags, request_rec *r, server_rec *s)
int ap_proxy_hex2c(const char *x)
enctype
Definition: mod_proxy.h:75
apr_status_t ajp_handle_cping_cpong(apr_socket_t *sock, request_rec *r, apr_interval_time_t timeout)
char * ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t, int forcedec, int proxyreq)
int ap_proxy_spool_input(request_rec *r, proxy_conn_rec *backend, apr_bucket_brigade *input_brigade, apr_off_t *bytes_spooled, apr_off_t max_mem_spool)
hcmethod_t
Definition: mod_proxy.h:83
int ap_proxy_trans_match(request_rec *r, struct proxy_alias *ent, proxy_dir_conf *dconf)
void ap_proxy_fill_error_brigade(request_rec *r, int status, apr_bucket_brigade *bb, int eoc)
void ap_proxy_c2hex(int ch, char *x)
void ap_proxy_backend_broke(request_rec *r, apr_bucket_brigade *brigade)
proxy_worker_shared * ap_proxy_find_workershm(ap_slotmem_provider_t *storage, ap_slotmem_instance_t *slot, proxy_worker *worker, unsigned int *index)
int() proxy_is_best_callback_fn_t(proxy_worker *current, proxy_worker *prev_best, void *baton)
Definition: mod_proxy.h:981
int
Definition: mod_proxy.h:674
apr_status_t ap_proxy_tunnel_create(proxy_tunnel_rec **tunnel, request_rec *r, conn_rec *c_o, const char *scheme)
apr_status_t ap_proxy_check_connection(const char *scheme, proxy_conn_rec *conn, server_rec *server, unsigned max_blank_lines, int flags)
#define PROXY_WORKER_MAX_SECRET_SIZE
Definition: mod_proxy.h:388
int ap_proxy_post_request(proxy_worker *worker, proxy_balancer *balancer, request_rec *r, proxy_server_conf *conf)
char * ap_proxy_define_worker(apr_pool_t *p, proxy_worker **worker, proxy_balancer *balancer, proxy_server_conf *conf, const char *url, int do_malloc)
proxy_worker * worker
Definition: mod_proxy.h:657
int ap_proxy_connection_reusable(proxy_conn_rec *conn)
int ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf, const char *hostname, apr_sockaddr_t *addr)
#define PROXY_MAX_PROVIDER_NAME_SIZE
Definition: mod_proxy.h:398
#define PROXY_WORKER_MAX_NAME_SIZE
Definition: mod_proxy.h:383
const char apr_size_t dlen
Definition: mod_proxy.h:707
int ap_proxy_valid_balancer_name(char *name, int i)
#define PROXY_WORKER_MAX_SCHEME_SIZE
Definition: mod_proxy.h:380
int ap_proxy_pre_http_request(conn_rec *c, request_rec *r)
int ap_proxy_conn_is_https(conn_rec *c)
apr_status_t ap_proxy_share_worker(proxy_worker *worker, proxy_worker_shared *shm, int i)
int ap_proxy_worker_can_upgrade(apr_pool_t *p, const proxy_worker *worker, const char *upgrade, const char *dflt)
#define PROXY_BALANCER_MAX_HOSTNAME_SIZE
Definition: mod_proxy.h:386
apr_status_t ap_proxy_buckets_lifetime_transform(request_rec *r, apr_bucket_brigade *from, apr_bucket_brigade *to)
proxy_worker * proxy_balancer_get_best_worker(proxy_balancer *balancer, request_rec *r, proxy_is_best_callback_fn_t *is_best, void *baton)
#define PROXY_RFC1035_HOSTNAME_SIZE
Definition: mod_proxy.h:391
const char * ap_proxy_de_socketfy(apr_pool_t *p, const char *url)
int ap_proxy_pre_request(proxy_worker **worker, proxy_balancer **balancer, request_rec *r, proxy_server_conf *conf, char **url)
apr_status_t ap_proxy_connect_uds(apr_socket_t *sock, const char *uds_path, apr_pool_t *p)
void hc_show_exprs(request_rec *)
int ap_proxy_connect_to_backend(apr_socket_t **, const char *, apr_sockaddr_t *, const char *, proxy_server_conf *, request_rec *)
const char * ap_proxy_cookie_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *str)
apr_status_t ap_proxy_sync_balancer(proxy_balancer *b, server_rec *s, proxy_server_conf *conf)
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)
int ap_proxy_connection_create_ex(const char *proxy_function, proxy_conn_rec *conn, request_rec *r)
proxy_worker proxy_server_conf * conf
Definition: mod_proxy.h:657
apr_status_t ap_proxy_share_balancer(proxy_balancer *balancer, proxy_balancer_shared *shm, int i)
detach_backend
Definition: mod_proxy.h:674
apr_status_t ap_proxy_ssl_connection_cleanup(proxy_conn_rec *conn, request_rec *r)
#define PROXY_BALANCER_MAX_STICKY_SIZE
Definition: mod_proxy.h:387
unsigned int ap_proxy_hashfunc(const char *str, proxy_hash_t method)
int ap_proxy_retry_worker(const char *proxy_function, proxy_worker *worker, server_rec *s)
int ap_proxy_lb_workers(void)
apr_status_t ap_proxy_initialize_worker(proxy_worker *worker, server_rec *s, apr_pool_t *p)
PROXY_DECLARE_DATA proxy_hcmethods_t proxy_hcmethods[]
apr_port_t ap_proxy_port_of_scheme(const char *scheme)
int ap_proxy_create_hdrbrgd(apr_pool_t *p, apr_bucket_brigade *header_brigade, request_rec *r, proxy_conn_rec *p_conn, proxy_worker *worker, proxy_server_conf *conf, apr_uri_t *uri, char *url, char *server_portstr, char **old_cl_val, char **old_te_val)
int ap_proxyerror(request_rec *r, int statuscode, const char *message)
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)
int hc_valid_expr(request_rec *, const char *)
apr_status_t ap_proxy_initialize_balancer(proxy_balancer *balancer, server_rec *s, apr_pool_t *p)
request_rec * r
Definition: mod_proxy.h:675
proxy_worker * ap_proxy_get_worker(apr_pool_t *p, proxy_balancer *balancer, proxy_server_conf *conf, const char *url)
const char *(* ap_proxy_header_reverse_map_fn)(request_rec *, proxy_dir_conf *, const char *)
Definition: mod_proxy.h:749
const char * ap_proxy_worker_get_name(const proxy_worker *worker)
apr_status_t balancer_manage(request_rec *, apr_table_t *params)
proxy_hash_t
Definition: mod_proxy.h:1267
apr_off_t ap_proxy_tunnel_conn_bytes_out(const proxy_tunnel_conn_t *tc)
char * ap_proxy_define_match_worker(apr_pool_t *p, proxy_worker **worker, proxy_balancer *balancer, proxy_server_conf *conf, const char *url, int do_malloc)
apr_off_t ap_proxy_tunnel_conn_bytes_in(const proxy_tunnel_conn_t *tc)
#define PROXY_DECLARE_OPTIONAL_HOOK
Definition: mod_proxy.h:634
int ap_proxy_connection_create(const char *proxy_function, proxy_conn_rec *conn, conn_rec *c, server_rec *s)
int ap_proxy_ssl_enable(conn_rec *c)
proxy_balancer_shared * ap_proxy_find_balancershm(ap_slotmem_provider_t *storage, ap_slotmem_instance_t *slot, proxy_balancer *balancer, unsigned int *index)
proxy_worker * ap_proxy_get_worker_ex(apr_pool_t *p, proxy_balancer *balancer, proxy_server_conf *conf, const char *url, unsigned int mask)
char * ap_proxy_canonenc_ex(apr_pool_t *p, const char *x, int len, enum enctype t, int flags, int proxyreq)
proxy_worker * ap_proxy_balancer_get_best_worker(proxy_balancer *balancer, request_rec *r, proxy_is_best_callback_fn_t *is_best, void *baton)
const char * src
Definition: mod_proxy.h:706
proxy_worker proxy_server_conf char * url
Definition: mod_proxy.h:657
int ap_proxy_prefetch_input(request_rec *r, proxy_conn_rec *backend, apr_bucket_brigade *input_brigade, apr_read_type_e block, apr_off_t *bytes_read, apr_off_t max_read)
void hc_select_exprs(request_rec *, const char *)
const char * ap_proxy_location_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *url)
int ap_proxy_pass_brigade(apr_bucket_alloc_t *bucket_alloc, request_rec *r, proxy_conn_rec *p_conn, conn_rec *origin, apr_bucket_brigade *bb, int flush)
const char * set_worker_hc_param(apr_pool_t *, server_rec *, proxy_worker *, const char *, const char *, void *)
int ap_proxy_is_socket_connected(apr_socket_t *socket)
@ enc_user
Definition: mod_proxy.h:76
@ enc_path
Definition: mod_proxy.h:76
@ enc_fpath
Definition: mod_proxy.h:76
@ enc_parm
Definition: mod_proxy.h:76
@ enc_search
Definition: mod_proxy.h:76
@ HEAD
Definition: mod_proxy.h:84
@ HEAD11
Definition: mod_proxy.h:84
@ GET
Definition: mod_proxy.h:84
@ OPTIONS
Definition: mod_proxy.h:84
@ PROVIDER
Definition: mod_proxy.h:84
@ EOT
Definition: mod_proxy.h:84
@ GET11
Definition: mod_proxy.h:84
@ OPTIONS11
Definition: mod_proxy.h:84
@ TCP
Definition: mod_proxy.h:84
@ CPING
Definition: mod_proxy.h:84
@ NONE
Definition: mod_proxy.h:84
@ PROXY_HASHFUNC_DEFAULT
Definition: mod_proxy.h:1267
@ PROXY_HASHFUNC_FNV
Definition: mod_proxy.h:1267
@ PROXY_HASHFUNC_APR
Definition: mod_proxy.h:1267
int apr_status_t
Definition: apr_errno.h:44
apr_uint16_t apr_port_t
Definition: apr_network_io.h:230
int apr_int32_t
Definition: apr.h:347
unsigned int apr_uint32_t
Definition: apr.h:348
off_t apr_off_t
Definition: apr.h:396
size_t apr_size_t
Definition: apr.h:394
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
struct apr_table_t apr_table_t
Definition: apr_tables.h:56
apr_int64_t apr_interval_time_t
Definition: apr_time.h:55
apr_int64_t apr_time_t
Definition: apr_time.h:45
int fixups(request_rec *r)
Apache Configuration.
Apache connection library.
CORE HTTP Daemon.
Apache Logging library.
Command line options.
HTTP protocol handling.
Apache Request library.
SSL protocol handling.
Virtual Host package.
HTTP Daemon routines.
Definition: ap_regex.h:111
Definition: ap_slotmem.h:86
Definition: apr_tables.h:62
Definition: apr_buckets.h:263
Definition: apr_arch_global_mutex.h:23
Definition: apr_arch_poll_private.h:124
Definition: apr_network_io.h:239
Definition: apr_arch_networkio.h:37
Definition: apr_arch_thread_mutex.h:28
Definition: apr_uri.h:85
Structure to store things which are per connection.
Definition: httpd.h:1193
Definition: mod_proxy.h:142
int(* matcher)(struct dirconn_entry *This, request_rec *r)
Definition: mod_proxy.h:146
struct in_addr addr mask
Definition: mod_proxy.h:144
char * name
Definition: mod_proxy.h:143
struct apr_sockaddr_t * hostaddr
Definition: mod_proxy.h:145
Definition: http_config.h:348
Definition: mod_proxy.h:149
const char * name
Definition: mod_proxy.h:150
struct apr_sockaddr_t * addr
Definition: mod_proxy.h:151
Definition: mod_proxy.h:134
proxy_balancer * balancer
Definition: mod_proxy.h:139
const char * real
Definition: mod_proxy.h:135
unsigned int flags
Definition: mod_proxy.h:138
const char * fake
Definition: mod_proxy.h:136
ap_regex_t * regex
Definition: mod_proxy.h:137
Definition: mod_proxy.h:584
apr_status_t(* reset)(proxy_balancer *balancer, server_rec *s)
Definition: mod_proxy.h:589
apr_status_t(* age)(proxy_balancer *balancer, server_rec *s)
Definition: mod_proxy.h:590
apr_status_t(* updatelbstatus)(proxy_balancer *balancer, proxy_worker *elected, server_rec *s)
Definition: mod_proxy.h:591
const char * name
Definition: mod_proxy.h:585
void * context
Definition: mod_proxy.h:588
Definition: mod_proxy.h:528
unsigned int forcerecovery
Definition: mod_proxy.h:549
unsigned int max_attempts_set
Definition: mod_proxy.h:544
proxy_hashes hash
Definition: mod_proxy.h:541
unsigned int sticky_separator_set
Definition: mod_proxy.h:555
char sticky_separator
Definition: mod_proxy.h:550
unsigned int scolonsep
Definition: mod_proxy.h:543
unsigned int need_reset
Definition: mod_proxy.h:546
unsigned int vhosted
Definition: mod_proxy.h:547
unsigned int forcerecovery_set
Definition: mod_proxy.h:551
unsigned int nonce_set
Definition: mod_proxy.h:554
unsigned int inactive
Definition: mod_proxy.h:548
unsigned int sticky_force
Definition: mod_proxy.h:542
unsigned int was_malloced
Definition: mod_proxy.h:545
apr_interval_time_t timeout
Definition: mod_proxy.h:537
unsigned int sticky_force_set
Definition: mod_proxy.h:553
int max_attempts
Definition: mod_proxy.h:539
unsigned int scolonsep_set
Definition: mod_proxy.h:552
int index
Definition: mod_proxy.h:540
apr_time_t wupdated
Definition: mod_proxy.h:538
Definition: mod_proxy.h:560
unsigned int failontimeout_set
Definition: mod_proxy.h:578
int growth
Definition: mod_proxy.h:565
ap_slotmem_instance_t * wslot
Definition: mod_proxy.h:563
int max_workers
Definition: mod_proxy.h:566
ap_conf_vector_t * section_config
Definition: mod_proxy.h:581
proxy_balancer_shared * s
Definition: mod_proxy.h:576
apr_time_t wupdated
Definition: mod_proxy.h:568
ap_slotmem_provider_t * storage
Definition: mod_proxy.h:564
unsigned int lbmethod_set
Definition: mod_proxy.h:580
unsigned int growth_set
Definition: mod_proxy.h:579
apr_array_header_t * errstatuses
Definition: mod_proxy.h:562
proxy_server_conf * sconf
Definition: mod_proxy.h:574
apr_global_mutex_t * gmutex
Definition: mod_proxy.h:570
apr_thread_mutex_t * tmutex
Definition: mod_proxy.h:572
void * context
Definition: mod_proxy.h:575
proxy_balancer_method * lbmethod
Definition: mod_proxy.h:569
apr_array_header_t * workers
Definition: mod_proxy.h:561
int failontimeout
Definition: mod_proxy.h:577
proxy_hashes hash
Definition: mod_proxy.h:567
Definition: mod_proxy.h:304
float cache_completion
Definition: mod_proxy.h:305
int content_length
Definition: mod_proxy.h:306
Definition: mod_proxy.h:310
apr_pool_t * dns_pool
Definition: mod_proxy.h:315
proxy_conn_rec * conn
Definition: mod_proxy.h:314
apr_pool_t * pool
Definition: mod_proxy.h:311
apr_sockaddr_t * addr
Definition: mod_proxy.h:312
apr_reslist_t * res
Definition: mod_proxy.h:313
Definition: mod_proxy.h:274
const char * uds_path
Definition: mod_proxy.h:293
void * data
Definition: mod_proxy.h:284
const char * hostname
Definition: mod_proxy.h:280
apr_pool_t * pool
Definition: mod_proxy.h:279
void * forward
Definition: mod_proxy.h:285
unsigned int inreslist
Definition: mod_proxy.h:292
apr_bucket_brigade * tmp_bb
Definition: mod_proxy.h:295
struct proxy_address * address
Definition: mod_proxy.h:301
apr_pool_t * uds_pool
Definition: mod_proxy.h:299
apr_pool_t * scpool
Definition: mod_proxy.h:282
request_rec * r
Definition: mod_proxy.h:276
apr_sockaddr_t * addr
Definition: mod_proxy.h:281
apr_socket_t * sock
Definition: mod_proxy.h:283
apr_uint32_t flags
Definition: mod_proxy.h:286
unsigned int need_flush
Definition: mod_proxy.h:290
apr_pool_t * fwd_pool
Definition: mod_proxy.h:300
proxy_worker * worker
Definition: mod_proxy.h:278
apr_port_t port
Definition: mod_proxy.h:287
unsigned int is_ssl
Definition: mod_proxy.h:288
const char * ssl_hostname
Definition: mod_proxy.h:294
unsigned int close
Definition: mod_proxy.h:289
conn_rec * connection
Definition: mod_proxy.h:275
Definition: mod_proxy.h:214
apr_array_header_t * cookie_domains
Definition: mod_proxy.h:228
signed char interpolate_env
Definition: mod_proxy.h:230
unsigned int add_forwarded_headers_set
Definition: mod_proxy.h:247
apr_array_header_t * raliases
Definition: mod_proxy.h:226
unsigned int error_override_set
Definition: mod_proxy.h:244
unsigned int error_override
Definition: mod_proxy.h:241
unsigned int alias_set
Definition: mod_proxy.h:245
apr_array_header_t * refs
Definition: mod_proxy.h:250
ap_regex_t * r
Definition: mod_proxy.h:216
struct proxy_alias * alias
Definition: mod_proxy.h:231
apr_interval_time_t async_idle_timeout
Definition: mod_proxy.h:258
unsigned int async_delay_set
Definition: mod_proxy.h:259
unsigned int forward_100_continue
Definition: mod_proxy.h:252
unsigned int async_idle_timeout_set
Definition: mod_proxy.h:260
unsigned int preserve_host_set
Definition: mod_proxy.h:243
signed char p_is_fnmatch
Definition: mod_proxy.h:229
unsigned int preserve_host
Definition: mod_proxy.h:242
const char * p
Definition: mod_proxy.h:215
apr_array_header_t * cookie_paths
Definition: mod_proxy.h:227
unsigned int forward_100_continue_set
Definition: mod_proxy.h:253
unsigned int add_forwarded_headers
Definition: mod_proxy.h:246
apr_interval_time_t async_delay
Definition: mod_proxy.h:257
apr_array_header_t * error_override_codes
Definition: mod_proxy.h:255
Definition: mod_proxy.h:422
unsigned int fnv
Definition: mod_proxy.h:424
unsigned int def
Definition: mod_proxy.h:423
Definition: mod_proxy.h:87
int implemented
Definition: mod_proxy.h:90
char * name
Definition: mod_proxy.h:89
hcmethod_t method
Definition: mod_proxy.h:88
Definition: mod_proxy.h:119
const char * hostname
Definition: mod_proxy.h:122
const char * protocol
Definition: mod_proxy.h:121
const char * creds
Definition: mod_proxy.h:124
apr_port_t port
Definition: mod_proxy.h:126
int use_regex
Definition: mod_proxy.h:125
ap_regex_t * regexp
Definition: mod_proxy.h:123
const char * scheme
Definition: mod_proxy.h:120
Definition: mod_proxy.h:266
apr_array_header_t * cookie_domains
Definition: mod_proxy.h:269
apr_array_header_t * raliases
Definition: mod_proxy.h:267
apr_array_header_t * cookie_paths
Definition: mod_proxy.h:268
Definition: mod_proxy.h:154
unsigned int req_set
Definition: mod_proxy.h:195
unsigned int map_encoded_all
Definition: mod_proxy.h:211
apr_size_t recv_buffer_size
Definition: mod_proxy.h:176
unsigned int viaopt_set
Definition: mod_proxy.h:196
unsigned int bgrowth_set
Definition: mod_proxy.h:204
apr_array_header_t * workers
Definition: mod_proxy.h:160
int req
Definition: mod_proxy.h:167
const char * id
Definition: mod_proxy.h:165
apr_array_header_t * aliases
Definition: mod_proxy.h:157
apr_array_header_t * proxies
Definition: mod_proxy.h:155
unsigned int recv_buffer_size_set
Definition: mod_proxy.h:197
proxy_worker * forward
Definition: mod_proxy.h:162
apr_array_header_t * sec_proxy
Definition: mod_proxy.h:156
unsigned int source_address_set
Definition: mod_proxy.h:203
const char * domain
Definition: mod_proxy.h:164
unsigned int timeout_set
Definition: mod_proxy.h:200
apr_sockaddr_t * source_address
Definition: mod_proxy.h:190
ap_slotmem_provider_t * storage
Definition: mod_proxy.h:193
unsigned int maxfwd_set
Definition: mod_proxy.h:199
unsigned int inherit
Definition: mod_proxy.h:206
long maxfwd
Definition: mod_proxy.h:178
unsigned int proxy_status_set
Definition: mod_proxy.h:202
unsigned int io_buffer_size_set
Definition: mod_proxy.h:198
apr_pool_t * pool
Definition: mod_proxy.h:166
apr_interval_time_t timeout
Definition: mod_proxy.h:179
unsigned int badopt_set
Definition: mod_proxy.h:201
@ via_block
Definition: mod_proxy.h:173
@ via_on
Definition: mod_proxy.h:172
@ via_off
Definition: mod_proxy.h:171
apr_array_header_t * dirconn
Definition: mod_proxy.h:159
apr_global_mutex_t * mutex
Definition: mod_proxy.h:191
unsigned int map_encoded_one
Definition: mod_proxy.h:210
unsigned int bal_persist
Definition: mod_proxy.h:205
apr_size_t io_buffer_size
Definition: mod_proxy.h:177
unsigned int inherit_set
Definition: mod_proxy.h:207
unsigned int ppinherit
Definition: mod_proxy.h:208
int bgrowth
Definition: mod_proxy.h:169
@ bad_ignore
Definition: mod_proxy.h:182
@ bad_error
Definition: mod_proxy.h:181
apr_array_header_t * balancers
Definition: mod_proxy.h:161
ap_slotmem_instance_t * bslot
Definition: mod_proxy.h:192
proxy_worker * reverse
Definition: mod_proxy.h:163
@ status_on
Definition: mod_proxy.h:187
@ status_off
Definition: mod_proxy.h:186
int max_balancers
Definition: mod_proxy.h:168
apr_array_header_t * noproxies
Definition: mod_proxy.h:158
unsigned int ppinherit_set
Definition: mod_proxy.h:209
Definition: mod_proxy.h:1409
apr_interval_time_t timeout
Definition: mod_proxy.h:1414
apr_size_t read_buf_size
Definition: mod_proxy.h:1417
proxy_tunnel_conn_t * origin
Definition: mod_proxy.h:1416
proxy_tunnel_conn_t * client
Definition: mod_proxy.h:1415
request_rec * r
Definition: mod_proxy.h:1410
apr_array_header_t * pfds
Definition: mod_proxy.h:1413
unsigned int nohalfclose
Definition: mod_proxy.h:1419
int replied
Definition: mod_proxy.h:1418
apr_pollset_t * pollset
Definition: mod_proxy.h:1412
const char * scheme
Definition: mod_proxy.h:1411
Definition: mod_proxy.h:428
apr_interval_time_t ttl
Definition: mod_proxy.h:464
unsigned int conn_timeout_set
Definition: mod_proxy.h:488
unsigned int keepalive
Definition: mod_proxy.h:481
unsigned int timeout_set
Definition: mod_proxy.h:485
int fcount
Definition: mod_proxy.h:453
apr_size_t recv_buffer_size
Definition: mod_proxy.h:472
apr_interval_time_t timeout
Definition: mod_proxy.h:467
apr_time_t updated
Definition: mod_proxy.h:462
hcmethod_t method
Definition: mod_proxy.h:461
apr_off_t transferred
Definition: mod_proxy.h:478
unsigned int is_name_matchable
Definition: mod_proxy.h:494
int flush_wait
Definition: mod_proxy.h:448
apr_uint32_t address_expiry
Definition: mod_proxy.h:498
int pcount
Definition: mod_proxy.h:451
int smax
Definition: mod_proxy.h:446
apr_time_t error_time
Definition: mod_proxy.h:463
apr_interval_time_t retry
Definition: mod_proxy.h:466
unsigned int was_malloced
Definition: mod_proxy.h:493
unsigned int ping_timeout_set
Definition: mod_proxy.h:487
unsigned int disablereuse_set
Definition: mod_proxy.h:492
void * context
Definition: mod_proxy.h:480
int retries
Definition: mod_proxy.h:442
apr_size_t response_field_size
Definition: mod_proxy.h:476
int hmax
Definition: mod_proxy.h:447
unsigned int status
Definition: mod_proxy.h:455
apr_size_t elected
Definition: mod_proxy.h:474
unsigned int io_buffer_size_set
Definition: mod_proxy.h:490
unsigned int keepalive_set
Definition: mod_proxy.h:491
int index
Definition: mod_proxy.h:449
apr_size_t io_buffer_size
Definition: mod_proxy.h:473
@ flush_on
Definition: mod_proxy.h:458
@ flush_off
Definition: mod_proxy.h:457
int lbstatus
Definition: mod_proxy.h:443
unsigned int address_ttl_set
Definition: mod_proxy.h:496
apr_interval_time_t interval
Definition: mod_proxy.h:471
apr_interval_time_t conn_timeout
Definition: mod_proxy.h:470
proxy_hashes hash
Definition: mod_proxy.h:454
int fails
Definition: mod_proxy.h:452
apr_port_t port
Definition: mod_proxy.h:477
unsigned int response_field_size_set
Definition: mod_proxy.h:495
unsigned int retry_set
Definition: mod_proxy.h:484
int lbfactor
Definition: mod_proxy.h:444
int lbset
Definition: mod_proxy.h:441
apr_int32_t address_ttl
Definition: mod_proxy.h:497
apr_interval_time_t ping_timeout
Definition: mod_proxy.h:469
unsigned int recv_buffer_size_set
Definition: mod_proxy.h:489
unsigned int is_address_reusable
Definition: mod_proxy.h:483
unsigned int disablereuse
Definition: mod_proxy.h:482
apr_size_t busy
Definition: mod_proxy.h:475
int passes
Definition: mod_proxy.h:450
int min
Definition: mod_proxy.h:445
apr_off_t read
Definition: mod_proxy.h:479
apr_interval_time_t acquire
Definition: mod_proxy.h:468
unsigned int acquire_set
Definition: mod_proxy.h:486
Definition: mod_proxy.h:504
unsigned int local_status
Definition: mod_proxy.h:506
const char * uds_name
Definition: mod_proxy.h:516
apr_thread_mutex_t * tmutex
Definition: mod_proxy.h:511
ap_conf_vector_t * section_config
Definition: mod_proxy.h:514
proxy_balancer * balancer
Definition: mod_proxy.h:509
struct proxy_address *volatile address
Definition: mod_proxy.h:515
proxy_conn_pool * cp
Definition: mod_proxy.h:507
proxy_worker_shared * s
Definition: mod_proxy.h:508
void * context
Definition: mod_proxy.h:513
proxy_hashes hash
Definition: mod_proxy.h:505
Definition: mod_proxy.h:93
unsigned int bit
Definition: mod_proxy.h:94
const char * name
Definition: mod_proxy.h:96
char flag
Definition: mod_proxy.h:95
A structure that represents the current request.
Definition: httpd.h:856
A structure to store information for each virtual server.
Definition: httpd.h:1382
apr_pool_t * p
Utilities for EBCDIC conversion.
Apache filter library.
Apache Mutex support library.