mod_proxy.h revision f921cd430a2ea23fcaedfdfc7439163f63c8472a
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Licensed to the Apache Software Foundation (ASF) under one or more
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * contributor license agreements. See the NOTICE file distributed with
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * this work for additional information regarding copyright ownership.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * The ASF licenses this file to You under the Apache License, Version 2.0
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * (the "License"); you may not use this file except in compliance with
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * the License. You may obtain a copy of the License at
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * http://www.apache.org/licenses/LICENSE-2.0
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Unless required by applicable law or agreed to in writing, software
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * distributed under the License is distributed on an "AS IS" BASIS,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * See the License for the specific language governing permissions and
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * limitations under the License.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#ifndef MOD_PROXY_H
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define MOD_PROXY_H
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @file mod_proxy.h
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @brief Proxy Extension Module for Apache
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @defgroup MOD_PROXY mod_proxy
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @ingroup APACHE_MODS
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @{
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/*
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding Also note numerous FIXMEs and CHECKMEs which should be eliminated.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding This code is once again experimental!
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding Things to do:
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding 1. Make it completely work (for FTP too)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding 2. HTTP/1.1
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding Chuck Murcko <chuck@topsail.org> 02-06-01
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_hooks.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_lib.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_strings.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_buckets.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_md5.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_network_io.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_pools.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_strings.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_uri.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_date.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_strmatch.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_fnmatch.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_reslist.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define APR_WANT_STRFUNC
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "apr_want.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "httpd.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "http_config.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "ap_config.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "http_core.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "http_protocol.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "http_request.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "http_vhost.h"
51af95bb51b5084e883bad250b2afa2838e9ceebfielding#include "http_main.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "http_log.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "http_connection.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "util_filter.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "util_ebcdic.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include "ap_provider.h"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#if APR_HAVE_NETINET_IN_H
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include <netinet/in.h>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#if APR_HAVE_ARPA_INET_H
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#include <arpa/inet.h>
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* for proxy_canonenc() */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingenum enctype {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding enc_path, enc_search, enc_user, enc_fpath, enc_parm
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding};
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#if APR_CHARSET_EBCDIC
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define CRLF "\r\n"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#else /*APR_CHARSET_EBCDIC*/
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define CRLF "\015\012"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif /*APR_CHARSET_EBCDIC*/
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* default Max-Forwards header setting */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Set this to -1, which complies with RFC2616 by not setting
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * max-forwards if the client didn't send it to us.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define DEFAULT_MAX_FORWARDS -1
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* static information about a remote proxy */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstruct proxy_remote {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *scheme; /* the schemes handled by this proxy, or '*' */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *protocol; /* the scheme used to talk to this proxy */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *hostname; /* the hostname of this proxy */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_port_t port; /* the port for this proxy */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_regex_t *regexp; /* compiled regex (if any) for the remote */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int use_regex; /* simple boolean. True if we have a regex pattern */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding};
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXYPASS_NOCANON 0x01
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXYPASS_INTERPOLATE 0x02
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstruct proxy_alias {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *real;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *fake;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_regex_t *regex;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding unsigned int flags;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding};
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstruct dirconn_entry {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char *name;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding struct in_addr addr, mask;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding struct apr_sockaddr_t *hostaddr;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int (*matcher) (struct dirconn_entry * This, request_rec *r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding};
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstruct noproxy_entry {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *name;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding struct apr_sockaddr_t *addr;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding};
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct proxy_balancer proxy_balancer;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct proxy_worker proxy_worker;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct proxy_conn_pool proxy_conn_pool;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct proxy_balancer_method proxy_balancer_method;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t *proxies;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t *sec_proxy;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t *aliases;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t *noproxies;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t *dirconn;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t *allowed_connect_ports;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t *workers;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t *balancers;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_worker *forward; /* forward proxy worker */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_worker *reverse; /* reverse "module-driven" proxy worker */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *domain; /* domain name to use in absence of a domain name in the request */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int req; /* true if proxy requests are enabled */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char req_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding enum {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding via_off,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding via_on,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding via_block,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding via_full
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding } viaopt; /* how to deal with proxy Via: headers */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char viaopt_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_size_t recv_buffer_size;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char recv_buffer_size_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_size_t io_buffer_size;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char io_buffer_size_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding long maxfwd;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char maxfwd_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * the following setting masks the error page
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * returned from the 'proxied server' and just
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * forwards the status code upwards.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * This allows the main server (us) to generate
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * the error page, (so it will look like a error
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * returned from the rest of the system
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int error_override;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int error_override_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int preserve_host;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int preserve_host_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_interval_time_t timeout;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char timeout_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding enum {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding bad_error,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding bad_ignore,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding bad_body
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding } badopt; /* how to deal with bad headers */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char badopt_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* putting new stuff on the end maximises binary back-compatibility.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * the strmatch_patterns are really a const just to have a
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * case-independent strstr.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding enum {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding status_off,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding status_on,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding status_full
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding } proxy_status; /* Status display options */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char proxy_status_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_pool_t *pool; /* Pool used for allocating this struct */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding} proxy_server_conf;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *p; /* The path */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int p_is_fnmatch; /* Is this path an fnmatch candidate? */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_regex_t *r; /* Is this a regex? */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* ProxyPassReverse and friends are documented as working inside
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * <Location>. But in fact they never have done in the case of
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * more than one <Location>, because the server_conf can't see it.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * We need to move them to the per-dir config.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Discussed in February:
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * http://marc.theaimsgroup.com/?l=apache-httpd-dev&m=110726027118798&w=2
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t *raliases;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t* cookie_paths;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t* cookie_domains;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const apr_strmatch_pattern* cookie_path_str;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const apr_strmatch_pattern* cookie_domain_str;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *ftp_directory_charset;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int interpolate_env;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding} proxy_dir_conf;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* if we interpolate env vars per-request, we'll need a per-request
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * copy of the reverse proxy config
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t *raliases;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t* cookie_paths;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t* cookie_domains;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding} proxy_req_conf;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding conn_rec *connection;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *hostname;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_port_t port;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int is_ssl;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_pool_t *pool; /* Subpool for hostname and addr data */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_socket_t *sock; /* Connection socket */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_sockaddr_t *addr; /* Preparsed remote address info */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_uint32_t flags; /* Conection flags */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int close; /* Close 'this' connection */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_worker *worker; /* Connection pool this connection belongs to */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding void *data; /* per scheme connection data */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#if APR_HAS_THREADS
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int inreslist; /* connection in apr_reslist? */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_pool_t *scpool; /* Subpool used for socket and connection data */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding request_rec *r; /* Request record of the frontend request
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * which the backend currently answers. */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int need_flush;/* Flag to decide whether we need to flush the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * filter chain or not */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding} proxy_conn_rec;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding float cache_completion; /* completion percentage */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int content_length; /* length of the content */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding} proxy_completion;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Connection pool */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstruct proxy_conn_pool {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_pool_t *pool; /* The pool used in constructor and destructor calls */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_sockaddr_t *addr; /* Preparsed remote address info */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#if APR_HAS_THREADS
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_reslist_t *res; /* Connection resource list */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_conn_rec *conn; /* Single connection for prefork mpm's */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding};
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* worker status flags */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_WORKER_INITIALIZED 0x0001
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_WORKER_IGNORE_ERRORS 0x0002
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_WORKER_IN_SHUTDOWN 0x0010
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_WORKER_DISABLED 0x0020
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_WORKER_STOPPED 0x0040
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_WORKER_IN_ERROR 0x0080
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_WORKER_HOT_STANDBY 0x0100
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_WORKER_NOT_USABLE_BITMAP ( PROXY_WORKER_IN_SHUTDOWN | \
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_WORKER_DISABLED | PROXY_WORKER_STOPPED | PROXY_WORKER_IN_ERROR )
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* NOTE: these check the shared status */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_WORKER_IS_INITIALIZED(f) ( (f)->s && \
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ( (f)->s->status & PROXY_WORKER_INITIALIZED ) )
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_WORKER_IS_STANDBY(f) ( (f)->s && \
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ( (f)->s->status & PROXY_WORKER_HOT_STANDBY ) )
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_WORKER_IS_USABLE(f) ( (f)->s && \
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ( !( (f)->s->status & PROXY_WORKER_NOT_USABLE_BITMAP) ) && \
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding PROXY_WORKER_IS_INITIALIZED(f) )
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* default worker retry timeout in seconds */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_WORKER_DEFAULT_RETRY 60
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_WORKER_MAX_ROUTE_SIZ 63
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Runtime worker status informations. Shared in scoreboard */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int status;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_time_t error_time; /* time of the last error */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int retries; /* number of retries on this worker */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int lbstatus; /* Current lbstatus */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int lbfactor; /* dynamic lbfactor */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_off_t transferred;/* Number of bytes transferred to remote */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_off_t read; /* Number of bytes read from remote */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_size_t elected; /* Number of times the worker was elected */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char route[PROXY_WORKER_MAX_ROUTE_SIZ+1];
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char redirect[PROXY_WORKER_MAX_ROUTE_SIZ+1];
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding void *context; /* general purpose storage */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_size_t busy; /* busyness factor */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int lbset; /* load balancer cluster set */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding} proxy_worker_stat;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Worker configuration */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstruct proxy_worker {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int id; /* scoreboard id */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_interval_time_t retry; /* retry interval */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int lbfactor; /* initial load balancing factor */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *name;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *scheme; /* scheme to use ajp|http|https */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *hostname; /* remote backend address */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *route; /* balancing route */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *redirect; /* temporary balancing redirection route */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int status; /* temporary worker status */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_port_t port;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int min; /* Desired minimum number of available connections */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int smax; /* Soft maximum on the total number of connections */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int hmax; /* Hard maximum on the total number of connections */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_interval_time_t ttl; /* maximum amount of time in seconds a connection
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * may be available while exceeding the soft limit */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_interval_time_t timeout; /* connection timeout */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char timeout_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_interval_time_t acquire; /* acquire timeout when the maximum number of connections is exceeded */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char acquire_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_size_t recv_buffer_size;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char recv_buffer_size_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_size_t io_buffer_size;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char io_buffer_size_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char keepalive;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char keepalive_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_conn_pool *cp; /* Connection pool to use */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_worker_stat *s; /* Shared data */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding void *opaque; /* per scheme worker data */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int is_address_reusable;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#if APR_HAS_THREADS
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_thread_mutex_t *mutex; /* Thread lock for updating address cache */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding void *context; /* general purpose storage */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding enum {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding flush_off,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding flush_on,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding flush_auto
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding } flush_packets; /* control AJP flushing */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int flush_wait; /* poll wait time in microseconds if flush_auto */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_interval_time_t ping_timeout;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char ping_timeout_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int lbset; /* load balancer cluster set */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char retry_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char disablereuse;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char disablereuse_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_interval_time_t conn_timeout;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char conn_timeout_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding};
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/*
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Wait 10000 microseconds to find out if more data is currently
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * available at the backend. Just an arbitrary choose.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_FLUSH_WAIT 10000
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstruct proxy_balancer {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_array_header_t *workers; /* array of proxy_workers */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *name; /* name of the load balancer */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *sticky; /* sticky session identifier */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int sticky_force; /* Disable failover for sticky sessions */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_interval_time_t timeout; /* Timeout for waiting on free connection */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int max_attempts; /* Number of attempts before failing */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char max_attempts_set;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_balancer_method *lbmethod;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* XXX: Perhaps we will need the proc mutex too.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Altrough we are only using arithmetic operations
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * it may lead to a incorrect calculations.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * For now use only the thread mutex.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#if APR_HAS_THREADS
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_thread_mutex_t *mutex; /* Thread lock for updating lb params */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding void *context; /* general purpose storage */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *sticky_path; /* URL sticky session identifier */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding};
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstruct proxy_balancer_method {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *name; /* name of the load balancer method*/
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_worker *(*finder)(proxy_balancer *balancer,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding request_rec *r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding void *context; /* general purpose storage */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding};
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#if APR_HAS_THREADS
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_THREAD_LOCK(x) apr_thread_mutex_lock((x)->mutex)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_THREAD_UNLOCK(x) apr_thread_mutex_unlock((x)->mutex)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#else
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_THREAD_LOCK(x) APR_SUCCESS
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_THREAD_UNLOCK(x) APR_SUCCESS
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* hooks */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Create a set of PROXY_DECLARE(type), PROXY_DECLARE_NONSTD(type) and
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * PROXY_DECLARE_DATA with appropriate export and import tags for the platform
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#if !defined(WIN32)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_DECLARE(type) type
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_DECLARE_NONSTD(type) type
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_DECLARE_DATA
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#elif defined(PROXY_DECLARE_STATIC)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_DECLARE(type) type __stdcall
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_DECLARE_NONSTD(type) type
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_DECLARE_DATA
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#elif defined(PROXY_DECLARE_EXPORT)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_DECLARE(type) __declspec(dllexport) type __stdcall
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_DECLARE_NONSTD(type) __declspec(dllexport) type
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_DECLARE_DATA __declspec(dllexport)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#else
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_DECLARE(type) __declspec(dllimport) type __stdcall
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_DECLARE_NONSTD(type) __declspec(dllimport) type
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_DECLARE_DATA __declspec(dllimport)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Hook an optional proxy hook. Unlike static hooks, this uses a macro
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * instead of a function.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_OPTIONAL_HOOK(name,fn,pre,succ,order) \
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding APR_OPTIONAL_HOOK(proxy,name,fn,pre,succ,order)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, scheme_handler, (request_rec *r,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_worker *worker, proxy_server_conf *conf, char *url,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *proxyhost, apr_port_t proxyport))
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, canon_handler, (request_rec *r,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char *url))
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, create_req, (request_rec *r, request_rec *pr))
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, fixups, (request_rec *r))
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * pre request hook.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * It will return the most suitable worker at the moment
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * and coresponding balancer.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * The url is rewritten from balancer://cluster/uri to scheme://host:port/uri
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * and then the scheme_handler is called.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, pre_request, (proxy_worker **worker,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_balancer **balancer,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding request_rec *r,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_server_conf *conf, char **url))
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * post request hook.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * It is called after request for updating runtime balancer status.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, post_request, (proxy_worker *worker,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_balancer *balancer, request_rec *r,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_server_conf *conf))
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * request status hook
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * It is called after all proxy processing has been done. This gives other
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * modules a chance to create default content on failure, for example
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingAPR_DECLARE_EXTERNAL_HOOK(proxy, PROXY, int, request_status,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding (int *status, request_rec *r))
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* proxy_util.c */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(request_rec *)ap_proxy_make_fake_req(conn_rec *c, request_rec *r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_hex2c(const char *x);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(void) ap_proxy_c2hex(int ch, char *x);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(char *)ap_proxy_canonenc(apr_pool_t *p, const char *x, int len, enum enctype t,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int forcedec, int proxyreq);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(char *)ap_proxy_canon_netloc(apr_pool_t *p, char **const urlp, char **userp,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char **passwordp, char **hostp, apr_port_t *port);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(const char *)ap_proxy_date_canon(apr_pool_t *p, const char *x);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_liststr(const char *list, const char *val);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(char *)ap_proxy_removestr(apr_pool_t *pool, const char *list, const char *val);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_hex2sec(const char *x);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(void) ap_proxy_sec2hex(int t, char *y);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxyerror(request_rec *r, int statuscode, const char *message);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_is_ipaddr(struct dirconn_entry *This, apr_pool_t *p);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_is_domainname(struct dirconn_entry *This, apr_pool_t *p);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_is_hostname(struct dirconn_entry *This, apr_pool_t *p);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_is_word(struct dirconn_entry *This, apr_pool_t *p);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_checkproxyblock(request_rec *r, proxy_server_conf *conf, apr_sockaddr_t *uri_addr);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_pre_http_request(conn_rec *c, request_rec *r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(apr_status_t) ap_proxy_string_read(conn_rec *c, apr_bucket_brigade *bb, char *buff, size_t bufflen, int *eos);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(void) ap_proxy_table_unmerge(apr_pool_t *p, apr_table_t *t, char *key);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* DEPRECATED (will be replaced with ap_proxy_connect_backend */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_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 *);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(apr_status_t) ap_proxy_ssl_connection_cleanup(proxy_conn_rec *conn,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding request_rec *r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_ssl_enable(conn_rec *c);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_ssl_disable(conn_rec *c);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_conn_is_https(conn_rec *c);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(const char *) ap_proxy_ssl_val(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r, const char *var);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Header mapping functions, and a typedef of their signature */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(const char *) ap_proxy_location_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *url);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(const char *) ap_proxy_cookie_reverse_map(request_rec *r, proxy_dir_conf *conf, const char *str);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#if !defined(WIN32)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef const char *(*ap_proxy_header_reverse_map_fn)(request_rec *,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_dir_conf *, const char *);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#elif defined(PROXY_DECLARE_STATIC)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef const char *(__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_dir_conf *, const char *);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#elif defined(PROXY_DECLARE_EXPORT)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef __declspec(dllexport) const char *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding (__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_dir_conf *, const char *);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#else
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef __declspec(dllimport) const char *
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding (__stdcall *ap_proxy_header_reverse_map_fn)(request_rec *,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_dir_conf *, const char *);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* Connection pool API */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Get the worker from proxy configuration
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param p memory pool used for finding worker
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param conf current proxy server configuration
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param url url to find the worker from
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return proxy_worker or NULL if not found
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_server_conf *conf,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *url);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Add the worker to proxy configuration
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param worker the new worker
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param p memory pool to allocate worker from
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param conf current proxy server configuration
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param url url containing worker name
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return error message or NULL if successfull
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(const char *) ap_proxy_add_worker(proxy_worker **worker,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_pool_t *p,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_server_conf *conf,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *url);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Create new worker
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param p memory pool to allocate worker from
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return new worker
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(proxy_worker *) ap_proxy_create_worker(apr_pool_t *p);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Initize the worker's shared data
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param conf current proxy server configuration
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param worker worker to initialize
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param s current server record
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param worker worker to initialize
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(void) ap_proxy_initialize_worker_share(proxy_server_conf *conf,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_worker *worker,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding server_rec *s);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Initize the worker
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param worker worker to initialize
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param s current server record
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return APR_SUCCESS or error code
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(apr_status_t) ap_proxy_initialize_worker(proxy_worker *worker,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding server_rec *s);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Get the balancer from proxy configuration
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param p memory pool used for finding balancer
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param conf current proxy server configuration
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param url url to find the worker from. Has to have balancer:// prefix
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return proxy_balancer or NULL if not found
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(proxy_balancer *) ap_proxy_get_balancer(apr_pool_t *p,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_server_conf *conf,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *url);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Add the balancer to proxy configuration
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param balancer the new balancer
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param p memory pool to allocate balancer from
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param conf current proxy server configuration
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param url url containing balancer name
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return error message or NULL if successfull
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(const char *) ap_proxy_add_balancer(proxy_balancer **balancer,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_pool_t *p,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_server_conf *conf,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *url);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Add the worker to the balancer
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param pool memory pool for adding worker
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param balancer balancer to add to
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param balancer worker to add
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @note Single worker can be added to multiple balancers.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(void) ap_proxy_add_worker_to_balancer(apr_pool_t *pool,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_balancer *balancer,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_worker *worker);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Get the most suitable worker and(or) balancer for the request
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param worker worker used for processing request
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param balancer balancer used for processing request
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param r current request
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param conf current proxy server configuration
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param url request url that balancer can rewrite.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return OK or HTTP_XXX error
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @note It calls balancer pre_request hook if the url starts with balancer://
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * The balancer then rewrites the url to particular worker, like http://host:port
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_balancer **balancer,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding request_rec *r,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_server_conf *conf,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char **url);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Post request worker and balancer cleanup
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param worker worker used for processing request
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param balancer balancer used for processing request
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param r current request
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param conf current proxy server configuration
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return OK or HTTP_XXX error
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @note When ever the pre_request is called, the post_request has to be
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * called too.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_post_request(proxy_worker *worker,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_balancer *balancer,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding request_rec *r,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_server_conf *conf);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Request status function
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param status status of proxy request
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return OK or DECLINED
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding PROXY_DECLARE(int) ap_proxy_request_status(int *status, request_rec *r);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Deternime backend hostname and port
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param p memory pool used for processing
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param r current request
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param conf current proxy server configuration
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param worker worker used for processing request
51af95bb51b5084e883bad250b2afa2838e9ceebfielding * @param conn proxy connection struct
51af95bb51b5084e883bad250b2afa2838e9ceebfielding * @param uri processed uri
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param url request url
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param proxyname are we connecting directly or via s proxy
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param proxyport proxy host port
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param server_portstr Via headers server port
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param server_portstr_size size of the server_portstr buffer
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return OK or HTTP_XXX error
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_determine_connection(apr_pool_t *p, request_rec *r,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_server_conf *conf,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_worker *worker,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_conn_rec *conn,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_uri_t *uri,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char **url,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding const char *proxyname,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_port_t proxyport,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding char *server_portstr,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding int server_portstr_size);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Mark a worker for retry
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param proxy_function calling proxy scheme (http, ajp, ...)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param conf current proxy server configuration
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param worker worker used for retrying
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param s current server record
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return OK if marked for retry, DECLINED otherwise
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @note Worker will be marker for retry if the time of the last retry
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * has been ellapsed. In case there is no retry option set, defaults to
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * number_of_retries seconds.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_retry_worker(const char *proxy_function,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_worker *worker,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding server_rec *s);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Acquire a connection from workers connection pool
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param proxy_function calling proxy scheme (http, ajp, ...)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param conn acquired connection
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param worker worker used for obtaining connection
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param s current server record
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return OK or HTTP_XXX error
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @note If the number of connections is exhaused the function will
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * block untill the timeout is reached.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_acquire_connection(const char *proxy_function,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_conn_rec **conn,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_worker *worker,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding server_rec *s);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Release a connection back to worker connection pool
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param proxy_function calling proxy scheme (http, ajp, ...)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param conn acquired connection
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param s current server record
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return OK or HTTP_XXX error
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @note The connection will be closed if conn->close_on_release is set
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_release_connection(const char *proxy_function,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_conn_rec *conn,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding server_rec *s);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Make a connection to the backend
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param proxy_function calling proxy scheme (http, ajp, ...)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param conn acquired connection
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param worker connection worker
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param s current server record
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return OK or HTTP_XXX error
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @note In case the socket already exists for conn, just check the link
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * status.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_connect_backend(const char *proxy_function,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_conn_rec *conn,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_worker *worker,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding server_rec *s);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Make a connection record for backend connection
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param proxy_function calling proxy scheme (http, ajp, ...)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param conn acquired connection
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param c client connection record
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param s current server record
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return OK or HTTP_XXX error
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(int) ap_proxy_connection_create(const char *proxy_function,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding proxy_conn_rec *conn,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding conn_rec *c, server_rec *s);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Signal the upstream chain that the connection to the backend broke in the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * middle of the response. This is done by sending an error bucket with
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * status HTTP_BAD_GATEWAY and an EOS bucket up the filter chain.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param r current request record of client request
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @param brigade The brigade that is sent through the output filter chain
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingPROXY_DECLARE(void) ap_proxy_backend_broke(request_rec *r,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding apr_bucket_brigade *brigade);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_LBMETHOD "proxylbmethod"
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* The number of dynamic workers that can be added when reconfiguring.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * If this limit is reached you must stop and restart the server.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#define PROXY_DYNAMIC_BALANCER_LIMIT 16
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/**
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Calculate number of maximum number of workers in scoreboard.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * @return number of workers to allocate in the scoreboard
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingint ap_proxy_lb_workers(void);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* For proxy_util */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingextern module PROXY_DECLARE_DATA proxy_module;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingextern int PROXY_DECLARE_DATA proxy_lb_workers;
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding#endif /*MOD_PROXY_H*/
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/** @} */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding