mod_proxy.c revision 7aeac3e3e334cb421641c1a317b5d926e9dbd44c
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* ====================================================================
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * The Apache Software License, Version 1.1
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd * reserved.
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * Redistribution and use in source and binary forms, with or without
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * modification, are permitted provided that the following conditions
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * are met:
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * 1. Redistributions of source code must retain the above copyright
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * notice, this list of conditions and the following disclaimer.
2e545ce2450a9953665f701bb05350f0d3f26275nd * 2. Redistributions in binary form must reproduce the above copyright
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * notice, this list of conditions and the following disclaimer in
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen * the documentation and/or other materials provided with the
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * distribution.
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen * 3. The end-user documentation included with the redistribution,
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * if any, must include the following acknowledgment:
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * "This product includes software developed by the
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * Apache Software Foundation (http://www.apache.org/)."
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * Alternately, this acknowledgment may appear in the software itself,
3f08db06526d6901aa08c110b5bc7dde6bc39905nd * if and wherever such third-party acknowledgments normally appear.
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung * 4. The names "Apache" and "Apache Software Foundation" must
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * not be used to endorse or promote products derived from this
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * software without prior written permission. For written
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * permission, please contact apache@apache.org.
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * 5. Products derived from this software may not be called "Apache",
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * nor may "Apache" appear in their name, without prior written
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * permission of the Apache Software Foundation.
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * SUCH DAMAGE.
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * ====================================================================
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * This software consists of voluntary contributions made by many
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * individuals on behalf of the Apache Software Foundation. For more
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * information on the Apache Software Foundation, please see
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * Portions of this software are based upon public domain software
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * originally written at the National Center for Supercomputing Applications,
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * University of Illinois, Urbana-Champaign.
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * A Web proxy module. Stages:
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * translate_name: set filename to proxy:<URL>
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * type_checker: set type to PROXY_MAGIC_TYPE if filename begins proxy:
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf * fix_ups: convert the URL stored in the filename to the
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * canonical form.
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * handler: handle proxy requests
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* -------------------------------------------------------------- */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* Translate the URL into a 'filename' */
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic int alias_match(const char *uri, const char *alias_fakename)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd const char *end_fakename = alias_fakename + strlen(alias_fakename);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* any number of '/' in the alias matches any number in
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * the supplied URI, but there must be at least one...
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf /* Other characters are compared literally */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* Check last alias path component matched all the way */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* Return number of characters from URI which matched (may be
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * greater than length of alias, since we may have matched
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * doubled slashes)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* Detect if an absoluteURI should be proxied or not. Note that we
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * have to do this during this phase because later phases are
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * "short-circuiting"... i.e. translate_names will end when the first
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * module returns OK. So for example, if the request is something like:
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * mod_alias will notice the /cgi-bin part and ScriptAlias it and
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * short-circuit the proxy... just because of the ordering in the
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * configuration file.
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd conf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* but it might be something vhosted */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd r->parsed_uri.port_str ? r->parsed_uri.port : ap_default_port(r)))) {
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd r->filename = apr_pstrcat(r->pool, "proxy:", r->uri, NULL);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* We need special treatment for CONNECT proxying: it has no scheme part */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd r->filename = apr_pstrcat(r->pool, "proxy:", r->uri, NULL);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd struct proxy_alias *ent = (struct proxy_alias *) conf->aliases->elts;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* someone has already set up the proxy, it was possibly ourselves
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * in proxy_detect
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* XXX: since r->uri has been manipulated already we're not really
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * compliant with RFC1945 at this point. But this probably isn't
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * an issue because this is a hybrid proxy/origin server.
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd if (len > 0) {
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd r->filename = apr_pstrcat(r->pool, "proxy:", ent[i].real,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* -------------------------------------------------------------- */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* Fixup the filename */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * Canonicalise the URL
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd char *url, *p;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* canonicalise each specific scheme */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* Send a redirection if the request contains a hostname which is not */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* fully qualified, i.e. doesn't have a domain name appended. Some proxy */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* servers like Netscape's allow this and access hosts from the local */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* domain in this case. I think it is better to redirect to a FQDN, since */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* these will later be found in the bookmarks files. */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* The "ProxyDomain" directive determines what domain will be appended */
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic int proxy_needsdomain(request_rec *r, const char *url, const char *domain)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd const char *ref;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* We only want to worry about GETs */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd if (!r->proxyreq || r->method_number != M_GET || !r->parsed_uri.hostname)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* If host does contain a dot already, or it is "localhost", decline */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* Reassemble the request, but insert the domain after the host name */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* Note that the domain name always starts with a dot */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd r->parsed_uri.hostname = apr_pstrcat(r->pool, r->parsed_uri.hostname,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_log_rerror(APLOG_MARK, APLOG_INFO|APLOG_NOERRNO, 0, r,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* -------------------------------------------------------------- */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* Invoke handler */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd const char *p2;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd struct proxy_remote *ents = (struct proxy_remote *) proxies->elts;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd const char *maxfwd_str;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd if ((r->method_number == M_TRACE || r->method_number == M_OPTIONS) &&
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd (maxfwd_str = apr_table_get(r->headers_in, "Max-Forwards")) != NULL) {
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd switch (r->method_number) {
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd apr_psprintf(r->pool, "%ld", (maxfwd > 0) ? maxfwd-1 : 0));
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)))
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd imstr = apr_table_get(r->headers_in, "If-Modified-Since");
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, NULL,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* If the host doesn't have a domain name, add one and redirect. */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd *p = '\0';
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* Check URI's destination host against NoProxy hosts */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* Bypass ProxyRemote server lookup if configured as NoProxy */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* we only know how to handle communication to a proxy via http */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /*if (strcasecmp(scheme, "http") == 0) */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd struct dirconn_entry *list = (struct dirconn_entry *) conf->dirconn->elts;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd for (direct_connect = ii = 0; ii < conf->dirconn->nelts && !direct_connect; ii++) {
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* firstly, try a proxy, unless a NoProxy directive is active */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd p2 = ap_strchr_c(ents[i].scheme, ':'); /* is it a partial URL? */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd (p2 == NULL && strcasecmp(scheme, ents[i].scheme) == 0) ||
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd strncasecmp(url, ents[i].scheme, strlen(ents[i].scheme)) == 0)) {
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* CONNECT is a special method that bypasses the normal
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * proxy code.
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* we only know how to handle communication to a proxy via http */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* an error or success */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* we failed to talk to the upstream proxy */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* otherwise, try it direct */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* N.B. what if we're behind a firewall, where we must use a proxy or
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * give up??
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* handle the scheme */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd "Neither CONNECT, HTTP or FTP for %s",
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* -------------------------------------------------------------- */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* Setup configurable data */
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic void * create_proxy_config(apr_pool_t *p, server_rec *s)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd proxy_server_conf *ps = ap_pcalloc(p, sizeof(proxy_server_conf));
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->proxies = ap_make_array(p, 10, sizeof(struct proxy_remote));
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->aliases = ap_make_array(p, 10, sizeof(struct proxy_alias));
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->raliases = ap_make_array(p, 10, sizeof(struct proxy_alias));
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->noproxies = ap_make_array(p, 10, sizeof(struct noproxy_entry));
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->dirconn = ap_make_array(p, 10, sizeof(struct dirconn_entry));
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->allowed_connect_ports = ap_make_array(p, 10, sizeof(int));
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->viaopt = via_off; /* initially backward compatible with 1.3.1 */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->recv_buffer_size = 0; /* this default was left unset for some reason */
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic void * merge_proxy_config(apr_pool_t *p, void *basev, void *overridesv)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd proxy_server_conf *ps = ap_pcalloc(p, sizeof(proxy_server_conf));
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd proxy_server_conf *overrides = (proxy_server_conf *) overridesv;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->proxies = ap_append_arrays(p, base->proxies, overrides->proxies);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->aliases = ap_append_arrays(p, base->aliases, overrides->aliases);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->raliases = ap_append_arrays(p, base->raliases, overrides->raliases);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->noproxies = ap_append_arrays(p, base->noproxies, overrides->noproxies);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->dirconn = ap_append_arrays(p, base->dirconn, overrides->dirconn);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->allowed_connect_ports = ap_append_arrays(p, base->allowed_connect_ports, overrides->allowed_connect_ports);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->domain = (overrides->domain == NULL) ? base->domain : overrides->domain;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->viaopt = (overrides->viaopt_set == 0) ? base->viaopt : overrides->viaopt;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->req = (overrides->req_set == 0) ? base->req : overrides->req;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ps->recv_buffer_size = (overrides->recv_buffer_size_set == 0) ? base->recv_buffer_size : overrides->recv_buffer_size;
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic const char *
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd add_proxy(cmd_parms *cmd, void *dummy, const char *f1, const char *r1)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd char *p, *q;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd char *r, *f, *scheme;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0') {
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd return "ProxyRemote: Bad syntax for a remote proxy server";
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd if (q != NULL) {
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd return "ProxyRemote: Bad syntax for a remote proxy server (bad port number)";
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd *q = '\0';
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd *p = '\0';
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic const char *
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd add_pass(cmd_parms *cmd, void *dummy, const char *f, const char *r)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic const char *
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd add_pass_reverse(cmd_parms *cmd, void *dummy, const char *f, const char *r)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd conf = (proxy_server_conf *)ap_get_module_config(s->module_config,
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic const char *
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd set_proxy_exclude(cmd_parms *parms, void *dummy, const char *arg)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd struct noproxy_entry *list = (struct noproxy_entry *) conf->noproxies->elts;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* Don't duplicate entries */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd if (apr_strnatcasecmp(arg, list[i].name) == 0) { /* ignore case for host names */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd if (APR_SUCCESS == apr_sockaddr_info_get(&addr, new->name, APR_UNSPEC, 0, 0, parms->pool)) {
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * Set the ports CONNECT can use
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic const char *
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd set_allowed_ports(cmd_parms *parms, void *dummy, const char *arg)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd return "AllowCONNECT: port number must be numeric";
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd/* Similar to set_proxy_exclude(), but defining directly connected hosts,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd * which should never be accessed via the configured ProxyRemote servers
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic const char *
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd set_proxy_dirconn(cmd_parms *parms, void *dummy, const char *arg)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd struct dirconn_entry *list = (struct dirconn_entry *) conf->dirconn->elts;
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* Don't duplicate entries */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic const char *
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd set_proxy_domain(cmd_parms *parms, void *dummy, const char *arg)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_get_module_config(parms->server->module_config, &proxy_module);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd return "ProxyDomain: domain name must start with a dot.";
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic const char *
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_get_module_config(parms->server->module_config, &proxy_module);
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic const char *
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd set_recv_buffer_size(cmd_parms *parms, void *dummy, const char *arg)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_get_module_config(parms->server->module_config, &proxy_module);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd if (s < 512 && s != 0) {
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd return "ProxyReceiveBufferSize must be >= 512 bytes, or 0 for system default.";
e9527d25af8ff3a40b1958aff04688d7df4e8e23ndstatic const char*
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd set_via_opt(cmd_parms *parms, void *dummy, const char *arg)
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_get_module_config(parms->server->module_config, &proxy_module);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd return "ProxyVia must be one of: "
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd "off | on | full | block";
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd AP_INIT_FLAG("ProxyRequests", set_proxy_req, NULL, RSRC_CONF,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd "on if the true proxy requests should be accepted"),
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd "a scheme, partial URL or '*' and a proxy server"),
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd "a virtual path and a URL"),
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd AP_INIT_TAKE2("ProxyPassReverse", add_pass_reverse, NULL, RSRC_CONF,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd "a virtual path and a URL for reverse proxy behaviour"),
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd AP_INIT_ITERATE("ProxyBlock", set_proxy_exclude, NULL, RSRC_CONF,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd "A list of names, hosts or domains to which the proxy will not connect"),
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd AP_INIT_TAKE1("ProxyReceiveBufferSize", set_recv_buffer_size, NULL, RSRC_CONF,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd "Receive buffer size for outgoing HTTP and FTP connections in bytes"),
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd AP_INIT_ITERATE("NoProxy", set_proxy_dirconn, NULL, RSRC_CONF,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd "A list of domains, hosts, or subnets to which the proxy will connect directly"),
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd AP_INIT_TAKE1("ProxyDomain", set_proxy_domain, NULL, RSRC_CONF,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd "The default intranet domain name (in absence of a domain in the URL)"),
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd AP_INIT_ITERATE("AllowCONNECT", set_allowed_ports, NULL, RSRC_CONF,
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd "A list of ports which CONNECT may connect to"),
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd "Configure Via: proxy header header to one of: on | off | block | full"),
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* handler */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_hook_handler(proxy_handler, NULL, NULL, APR_HOOK_FIRST);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* filename-to-URI translation */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_hook_translate_name(proxy_trans, NULL, NULL, APR_HOOK_FIRST);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* filters */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_register_output_filter("PROXY_SEND_DIR", ap_proxy_send_dir_filter, AP_FTYPE_CONNECTION);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* fixups */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd /* post read_request handling */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd ap_hook_post_read_request(proxy_detect, NULL, NULL, APR_HOOK_FIRST);
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd create_proxy_config, /* create per-server config structure */
e9527d25af8ff3a40b1958aff04688d7df4e8e23nd merge_proxy_config, /* merge per-server config structures */