mod_proxy.c revision d7387fcd4969206172e3a2a8bbcd25a3d7011ac5
842ae4bd224140319ae7feec1872b93dfd491143fielding/* ====================================================================
842ae4bd224140319ae7feec1872b93dfd491143fielding * The Apache Software License, Version 1.1
842ae4bd224140319ae7feec1872b93dfd491143fielding * Copyright (c) 2000 The Apache Software Foundation. All rights
842ae4bd224140319ae7feec1872b93dfd491143fielding * reserved.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Redistribution and use in source and binary forms, with or without
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * modification, are permitted provided that the following conditions
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * are met:
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 1. Redistributions of source code must retain the above copyright
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * notice, this list of conditions and the following disclaimer.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd * 2. Redistributions in binary form must reproduce the above copyright
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * notice, this list of conditions and the following disclaimer in
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * the documentation and/or other materials provided with the
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * distribution.
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * 3. The end-user documentation included with the redistribution,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * if any, must include the following acknowledgment:
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh * "This product includes software developed by the
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Apache Software Foundation (http://www.apache.org/)."
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Alternately, this acknowledgment may appear in the software itself,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * if and wherever such third-party acknowledgments normally appear.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * 4. The names "Apache" and "Apache Software Foundation" must
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * not be used to endorse or promote products derived from this
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * software without prior written permission. For written
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * permission, please contact apache@apache.org.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * 5. Products derived from this software may not be called "Apache",
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * nor may "Apache" appear in their name, without prior written
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * permission of the Apache Software Foundation.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
f888346b48f5e5b5e3f0a47dedb8cefd2759a4e2gregames * SUCH DAMAGE.
750d12c59545dbbac70390988de94f7e901b08f2niq * ====================================================================
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * This software consists of voluntary contributions made by many
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * individuals on behalf of the Apache Software Foundation. For more
db455cbc662c98dbbf53175393c50086ff63370cchrisd * information on the Apache Software Foundation, please see
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * Portions of this software are based upon public domain software
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * originally written at the National Center for Supercomputing Applications,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * University of Illinois, Urbana-Champaign.
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz/* Some WWW schemes and their default ports; this is basically /etc/services */
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz/* This will become global when the protocol abstraction comes */
18b5268e013574026b2503b1641baf3299045f45sf * A Web proxy module. Stages:
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * translate_name: set filename to proxy:<URL>
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * type_checker: set type to PROXY_MAGIC_TYPE if filename begins proxy:
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb * fix_ups: convert the URL stored in the filename to the
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * canonical form.
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * handler: handle proxy requests
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd/* -------------------------------------------------------------- */
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd/* Translate the URL into a 'filename' */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowestatic int alias_match(const char *uri, const char *alias_fakename)
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe const char *end_fakename = alias_fakename + strlen(alias_fakename);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* any number of '/' in the alias matches any number in
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar * the supplied URI, but there must be at least one...
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* Other characters are compared literally */
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf /* Check last alias path component matched all the way */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (aliasp[-1] != '/' && *urip != '\0' && *urip != '/')
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar /* Return number of characters from URI which matched (may be
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar * greater than length of alias, since we may have matched
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar * doubled slashes)
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar/* Detect if an absoluteURI should be proxied or not. Note that we
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar * have to do this during this phase because later phases are
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar * "short-circuiting"... i.e. translate_names will end when the first
8419e6f8bff1a3617933f3ba760d2bdec7442f44coar * module returns OK. So for example, if the request is something like:
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * mod_alias will notice the /cgi-bin part and ScriptAlias it and
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz * short-circuit the proxy... just because of the ordering in the
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * configuration file.
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe conf = (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe /* but it might be something vhosted */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe && !strcasecmp(r->parsed_uri.scheme, ap_http_method(r))
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf r->parsed_uri.port_str ? r->parsed_uri.port : ap_default_port(r)))) {
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf r->filename = apr_pstrcat(r->pool, "proxy:", r->uri, NULL);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* We need special treatment for CONNECT proxying: it has no scheme part */
c2cf53a40a9814eb91db2cdf820f97d943f21628coar r->filename = apr_pstrcat(r->pool, "proxy:", r->uri, NULL);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe (proxy_server_conf *) ap_get_module_config(sconf, &proxy_module);
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf struct proxy_alias *ent = (struct proxy_alias *) conf->aliases->elts;
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf /* someone has already set up the proxy, it was possibly ourselves
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * in proxy_detect
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe /* XXX: since r->uri has been manipulated already we're not really
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe * compliant with RFC1945 at this point. But this probably isn't
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe * an issue because this is a hybrid proxy/origin server.
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe r->filename = apr_pstrcat(r->pool, "proxy:", ent[i].real,
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes/* -------------------------------------------------------------- */
18b5268e013574026b2503b1641baf3299045f45sf/* Fixup the filename */
4f9c22c4f27571d54197be9674e1fc0d528192aestriker * Canonicalise the URL
18b5268e013574026b2503b1641baf3299045f45sf char *url, *p;
18b5268e013574026b2503b1641baf3299045f45sf if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0)
18b5268e013574026b2503b1641baf3299045f45sf/* canonicalise each specific scheme */
404381a78d109fd3a4a7702e69815e4d7ff6d93asf return ap_proxy_http_canon(r, url + 5, "http", DEFAULT_HTTP_PORT);
18b5268e013574026b2503b1641baf3299045f45sf/* Send a redirection if the request contains a hostname which is not */
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes/* fully qualified, i.e. doesn't have a domain name appended. Some proxy */
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes/* servers like Netscape's allow this and access hosts from the local */
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes/* domain in this case. I think it is better to redirect to a FQDN, since */
18b5268e013574026b2503b1641baf3299045f45sf/* these will later be found in the bookmarks files. */
18b5268e013574026b2503b1641baf3299045f45sf/* The "ProxyDomain" directive determines what domain will be appended */
18b5268e013574026b2503b1641baf3299045f45sfstatic int proxy_needsdomain(request_rec *r, const char *url, const char *domain)
18b5268e013574026b2503b1641baf3299045f45sf const char *ref;
4f9c22c4f27571d54197be9674e1fc0d528192aestriker /* We only want to worry about GETs */
18b5268e013574026b2503b1641baf3299045f45sf if (!r->proxyreq || r->method_number != M_GET || !r->parsed_uri.hostname)
18b5268e013574026b2503b1641baf3299045f45sf /* If host does contain a dot already, or it is "localhost", decline */
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes /* Reassemble the request, but insert the domain after the host name */
18b5268e013574026b2503b1641baf3299045f45sf /* Note that the domain name always starts with a dot */
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes r->parsed_uri.hostname = apr_pstrcat(r->pool, r->parsed_uri.hostname,
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe ap_log_rerror(APLOG_MARK, APLOG_INFO|APLOG_NOERRNO, 0, r,
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe/* -------------------------------------------------------------- */
d176cb9e596e4603f76490f9211f62b5581b3091rooneg/* Invoke handler */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe const char *p2;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe struct proxy_remote *ents = (struct proxy_remote *) proxies->elts;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe const char *maxfwd_str;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe if (!r->proxyreq || strncmp(r->filename, "proxy:", 6) != 0)
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe (maxfwd_str = apr_table_get(r->headers_in, "Max-Forwards")) != NULL) {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe apr_psprintf(r->pool, "%ld", (maxfwd > 0) ? maxfwd-1 : 0));
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe if ((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR)))
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd auth = apr_table_get(r->headers_in, "Authorization");
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd imstr = apr_table_get(r->headers_in, "If-Modified-Since");
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, NULL,
a2b181763cb35fd899feb4a436aeadaa80bf91eabrianp /* can this request be cached at all? */
4f9c22c4f27571d54197be9674e1fc0d528192aestriker if (r->method_number == M_GET && strlen(url) < 1024 &&
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd !ap_proxy_liststr(pragma, "no-cache") && auth == NULL)
4f9c22c4f27571d54197be9674e1fc0d528192aestriker if(ap_cache_seek(conf->cache, url, &cr) == APR_SUCCESS)
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd /* now we need to check if the last modified date is write if */
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd time_t ims = (time_t)ap_parseHTTPdate(ap_proxy_date_canon(r->pool, imstr));
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd /* ok we were asked to check, so let's do that */
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd ap_parseHTTPdate(ap_proxy_date_canon(r->pool, imstr)); if(lm != BAD_DATE)
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe return has_m ? HTTP_NOT_MODIFIED : ap_proxy_cache_send(r, cr);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* if there wasn't an entry in the cache we get here,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb we need to create one */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* If the host doesn't have a domain name, add one and redirect. */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb *p = '\0';
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* Check URI's destination host against NoProxy hosts */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* Bypass ProxyRemote server lookup if configured as NoProxy */
4f9c22c4f27571d54197be9674e1fc0d528192aestriker /* we only know how to handle communication to a proxy via http */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /*if (strcasecmp(scheme, "http") == 0) */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe struct dirconn_entry *list = (struct dirconn_entry *) conf->dirconn->elts;
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe for (direct_connect = ii = 0; ii < conf->dirconn->nelts && !direct_connect; ii++) {
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe ap_log_rerror(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, r,
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe (direct_connect) ? "NoProxy for %s" : "UseProxy for %s",
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe/* firstly, try a proxy, unless a NoProxy directive is active */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe p2 = ap_strchr_c(ents[i].scheme, ':'); /* is it a partial URL? */
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz (p2 == NULL && strcasecmp(scheme, ents[i].scheme) == 0) ||
1e911973bcb9df6701a4c16c037771ecf25ade13niq strncasecmp(url, ents[i].scheme, strlen(ents[i].scheme)) == 0)) {
1e911973bcb9df6701a4c16c037771ecf25ade13niq /* CONNECT is a special method that bypasses the normal
c3e233736c4a453cbb2166a041f779e86230630asf * proxy code.
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe rc = ap_proxy_connect_handler(r, cr, url, ents[i].hostname,
11fb2f3611e6ff9a541e10b13e3108934f828141gregames/* we only know how to handle communication to a proxy via http */
11fb2f3611e6ff9a541e10b13e3108934f828141gregames else if (strcasecmp(ents[i].protocol, "http") == 0)
11fb2f3611e6ff9a541e10b13e3108934f828141gregames rc = ap_proxy_http_handler(r, cr, url, ents[i].hostname,
4f9c22c4f27571d54197be9674e1fc0d528192aestriker /* an error or success */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* we failed to talk to the upstream proxy */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe/* otherwise, try it direct */
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar/* N.B. what if we're behind a firewall, where we must use a proxy or
c3e233736c4a453cbb2166a041f779e86230630asf * give up??
c3e233736c4a453cbb2166a041f779e86230630asf /* handle the scheme */
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar/* -------------------------------------------------------------- */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe/* Setup configurable data */
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowestatic void * create_proxy_config(apr_pool_t *p, server_rec *s)
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz proxy_server_conf *ps = ap_pcalloc(p, sizeof(proxy_server_conf));
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz ps->proxies = ap_make_array(p, 10, sizeof(struct proxy_remote));
4f9c22c4f27571d54197be9674e1fc0d528192aestriker ps->aliases = ap_make_array(p, 10, sizeof(struct proxy_alias));
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe ps->raliases = ap_make_array(p, 10, sizeof(struct proxy_alias));
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe ps->noproxies = ap_make_array(p, 10, sizeof(struct noproxy_entry));
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb ps->dirconn = ap_make_array(p, 10, sizeof(struct dirconn_entry));
8aefbd756763807188d2e3ce336a8680e4893066wrowe ps->nocaches = ap_make_array(p, 10, sizeof(struct nocache_entry));
700b96db75e7cfadb5219978c1735b710d583763wrowe ps->allowed_connect_ports = ap_make_array(p, 10, sizeof(int));
700b96db75e7cfadb5219978c1735b710d583763wrowe ps->viaopt = via_off; /* initially backward compatible with 1.3.1 */
700b96db75e7cfadb5219978c1735b710d583763wrowestatic const char *
700b96db75e7cfadb5219978c1735b710d583763wrowe add_proxy(cmd_parms *cmd, void *dummy, const char *f1, const char *r1)
700b96db75e7cfadb5219978c1735b710d583763wrowe (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
700b96db75e7cfadb5219978c1735b710d583763wrowe char *p, *q;
700b96db75e7cfadb5219978c1735b710d583763wrowe char *r, *f;
700b96db75e7cfadb5219978c1735b710d583763wrowe if (p == NULL || p[1] != '/' || p[2] != '/' || p[3] == '\0')
700b96db75e7cfadb5219978c1735b710d583763wrowe return "ProxyRemote: Bad syntax for a remote proxy server";
700b96db75e7cfadb5219978c1735b710d583763wrowe if (q != NULL) {
700b96db75e7cfadb5219978c1735b710d583763wrowe return "ProxyRemote: Bad syntax for a remote proxy server (bad port number)";
8aefbd756763807188d2e3ce336a8680e4893066wrowestatic const char *
8aefbd756763807188d2e3ce336a8680e4893066wrowe set_cache_exclude(cmd_parms *cmd, void *dummy, const char *arg)
8aefbd756763807188d2e3ce336a8680e4893066wrowe proxy_server_conf *psf = (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
8aefbd756763807188d2e3ce336a8680e4893066wrowe struct nocache_entry *list = (struct nocache_entry *) psf->nocaches->elts;
8aefbd756763807188d2e3ce336a8680e4893066wrowe /* Don't duplicate entries */
2fa5b5878e7567e2875807c3e2a2b3b0d3ef74bewrowe if (strcasecmp(arg, list[i].name) == 0) /* ignore case for host names */
a8d11d78181478da6a672f7fbc58b8d523351f49wrowe /* Don't do name lookups on things that aren't dotted */
23c6309e36a63b13b61c35999c978017521993d6wrowe /*@@@FIXME: This copies only the first of (possibly many) IP addrs */ memcpy(&new->addr, hp.h_addr, sizeof(struct in_addr));
23c6309e36a63b13b61c35999c978017521993d6wrowestatic const char *
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe add_pass(cmd_parms *cmd, void *dummy, const char *f, const char *r)
cf6ef072483172309861d06e85b1aeff4573c060wrowe (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
a8d11d78181478da6a672f7fbc58b8d523351f49wrowestatic const char *
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe add_pass_reverse(cmd_parms *cmd, void *dummy, const char *f, const char *r)
8aefbd756763807188d2e3ce336a8680e4893066wrowe conf = (proxy_server_conf *)ap_get_module_config(s->module_config,
cf6ef072483172309861d06e85b1aeff4573c060wrowestatic const char *
cf6ef072483172309861d06e85b1aeff4573c060wrowe set_proxy_exclude(cmd_parms *parms, void *dummy, const char *arg)
cf6ef072483172309861d06e85b1aeff4573c060wrowe ap_get_module_config(s->module_config, &proxy_module);
cf6ef072483172309861d06e85b1aeff4573c060wrowe struct noproxy_entry *list = (struct noproxy_entry *) conf->noproxies->elts;
d75626f0952c6152a99acd013a4f127d46f0f9edtrawick /* Don't duplicate entries */
d75626f0952c6152a99acd013a4f127d46f0f9edtrawick if (strcasecmp(arg, list[i].name) == 0) /* ignore case for host names */
ecde48c75338ff5712f2036711f813c6dedca28ewrowe /* Don't do name lookups on things that aren't dotted */
ecde48c75338ff5712f2036711f813c6dedca28ewrowe /*@@@FIXME: This copies only the first of (possibly many) IP addrs */
ecde48c75338ff5712f2036711f813c6dedca28ewrowe memcpy(&new->addr, hp.h_addr, sizeof(struct in_addr));
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * Set the ports CONNECT can use
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowestatic const char *
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe set_allowed_ports(cmd_parms *parms, void *dummy, const char *arg)
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd ap_get_module_config(s->module_config, &proxy_module);
4f9c22c4f27571d54197be9674e1fc0d528192aestriker return "AllowCONNECT: port number must be numeric";
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe/* Similar to set_proxy_exclude(), but defining directly connected hosts,
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe * which should never be accessed via the configured ProxyRemote servers
170476518c96db46fff6fdce7cb9a3f24abfaea7rpluemstatic const char *
a9a4544168a37b43bd180b3703ccee995f27a80awrowe set_proxy_dirconn(cmd_parms *parms, void *dummy, const char *arg)
170476518c96db46fff6fdce7cb9a3f24abfaea7rpluem ap_get_module_config(s->module_config, &proxy_module);
534611d341a1a48b93c7a1fd5e333dbd261527d3rpluem struct dirconn_entry *list = (struct dirconn_entry *) conf->dirconn->elts;
534611d341a1a48b93c7a1fd5e333dbd261527d3rpluem /* Don't duplicate entries */
eb12400ff685a3b69476736ca4b5389f348b9d63rpluem ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
eb12400ff685a3b69476736ca4b5389f348b9d63rpluem ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
ad099b4d62597be19f8dba650663e796cbaa8d28rpluem ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
ad099b4d62597be19f8dba650663e796cbaa8d28rpluem ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
534611d341a1a48b93c7a1fd5e333dbd261527d3rpluemstatic const char *
534611d341a1a48b93c7a1fd5e333dbd261527d3rpluem set_proxy_domain(cmd_parms *parms, void *dummy, const char *arg)
a9a4544168a37b43bd180b3703ccee995f27a80awrowe ap_get_module_config(parms->server->module_config, &proxy_module);
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe return "ProxyDomain: domain name must start with a dot.";
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowestatic const char *
8aefbd756763807188d2e3ce336a8680e4893066wrowe set_proxy_req(cmd_parms *parms, void *dummy, int flag)
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd ap_get_module_config(parms->server->module_config, &proxy_module);
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowestatic const char *
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe set_recv_buffer_size(cmd_parms *parms, void *dummy, const char *arg)
0e58e92812f2f679d6bf2ff66cbcfa6c1d1e14bbjerenkrantz ap_get_module_config(parms->server->module_config, &proxy_module);
0e58e92812f2f679d6bf2ff66cbcfa6c1d1e14bbjerenkrantz if (s < 512 && s != 0) {
cf6ef072483172309861d06e85b1aeff4573c060wrowe return "ProxyReceiveBufferSize must be >= 512 bytes, or 0 for system default.";
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowestatic const char*
2fd8d1e14fc47762d1e01660b544d5e2a75c825dtrawick set_via_opt(cmd_parms *parms, void *dummy, const char *arg)
e4a3f3c2f080cac75a15a6454cca429b8161c050wrowe ap_get_module_config(parms->server->module_config, &proxy_module);
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe return "ProxyVia must be one of: "
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe "off | on | full | block";
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowestatic const char*
4f9c22c4f27571d54197be9674e1fc0d528192aestriker set_cache_completion(cmd_parms *parms, void *dummy, const char *arg)
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe proxy_server_conf *psf = ap_get_module_config(parms->server->module_config, &proxy_module);
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe if (s > 100 || s < 0) {
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe return "CacheForceCompletion must be <= 100 percent, "
4f9c22c4f27571d54197be9674e1fc0d528192aestriker "or 0 for system default.";
4f9c22c4f27571d54197be9674e1fc0d528192aestriker AP_INIT_FLAG("ProxyRequests", set_proxy_req, NULL, RSRC_CONF,
4f9c22c4f27571d54197be9674e1fc0d528192aestriker "on if the true proxy requests should be accepted"),
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe AP_INIT_TAKE2("ProxyRemote", add_proxy, NULL, RSRC_CONF,
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe "a scheme, partial URL or '*' and a proxy server"),
4f9c22c4f27571d54197be9674e1fc0d528192aestriker AP_INIT_TAKE2("ProxyPass", add_pass, NULL, RSRC_CONF,
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe "a virtual path and a URL"),
4f9c22c4f27571d54197be9674e1fc0d528192aestriker AP_INIT_TAKE2("ProxyPassReverse", add_pass_reverse, NULL, RSRC_CONF,
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe "a virtual path and a URL for reverse proxy behaviour"),
4f9c22c4f27571d54197be9674e1fc0d528192aestriker AP_INIT_ITERATE("ProxyBlock", set_proxy_exclude, NULL, RSRC_CONF,
4f9c22c4f27571d54197be9674e1fc0d528192aestriker "A list of names, hosts or domains to which the proxy will not connect"),
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe AP_INIT_TAKE1("ProxyReceiveBufferSize", set_recv_buffer_size, NULL, RSRC_CONF,
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe "Receive buffer size for outgoing HTTP and FTP connections in bytes"),
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe AP_INIT_ITERATE("NoProxy", set_proxy_dirconn, NULL, RSRC_CONF,
4f9c22c4f27571d54197be9674e1fc0d528192aestriker "A list of domains, hosts, or subnets to which the proxy will connect directly"),
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe AP_INIT_TAKE1("ProxyDomain", set_proxy_domain, NULL, RSRC_CONF,
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe "The default intranet domain name (in absence of a domain in the URL)"),
4f9c22c4f27571d54197be9674e1fc0d528192aestriker AP_INIT_ITERATE("AllowCONNECT", set_allowed_ports, NULL, RSRC_CONF,
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe "A list of ports which CONNECT may connect to"),
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe AP_INIT_TAKE1("ProxyVia", set_via_opt, NULL, RSRC_CONF,
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe "Configure Via: proxy header header to one of: on | off | block | full"),
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe AP_INIT_ITERATE("ProxyNoCache", set_cache_exclude, NULL, RSRC_CONF,
4f9c22c4f27571d54197be9674e1fc0d528192aestriker "A list of names, hosts or domains for which caching is *not* provided"),
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe AP_INIT_TAKE1("ProxyCacheForceCompletion", set_cache_completion, NULL, RSRC_CONF,
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe "Force a http cache completion after this percentage is loaded"),
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowestatic void register_hooks(void)
cf6ef072483172309861d06e85b1aeff4573c060wrowe /* [2] filename-to-URI translation */
4f9c22c4f27571d54197be9674e1fc0d528192aestriker ap_hook_translate_name(proxy_trans, NULL, NULL, AP_HOOK_FIRST);
4f9c22c4f27571d54197be9674e1fc0d528192aestriker /* [8] fixups */
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe ap_hook_fixups(proxy_fixup, NULL, NULL, AP_HOOK_FIRST);
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe /* [1] post read_request handling */
1b315ee865b0f11e582beb64127ca3a99a319d2fwrowe ap_hook_post_read_request(proxy_detect, NULL, NULL, AP_HOOK_FIRST);
38bcc87d9a06e8ba81165421403f275eca4e313btrawick create_proxy_config, /* create per-server config structure */