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