mod_proxy.c revision 8a1e3e302a46f468054887a62abdbd9c98f3daa5
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova/* ====================================================================
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * The Apache Software License, Version 1.1
b43458b4d81f7451112cecbd757f3a05216e7088Kristina Sojakova * Copyright (c) 2000 The Apache Software Foundation. All rights
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu Prodescu * Redistribution and use in source and binary forms, with or without
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * modification, are permitted provided that the following conditions
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * 1. Redistributions of source code must retain the above copyright
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * notice, this list of conditions and the following disclaimer.
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * 2. Redistributions in binary form must reproduce the above copyright
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * notice, this list of conditions and the following disclaimer in
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova * the documentation and/or other materials provided with the
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova * distribution.
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * 3. The end-user documentation included with the redistribution,
9f85afecbd79b3df5a0bb17bd28cd0b288dc3213Kristina Sojakova * if any, must include the following acknowledgment:
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova * "This product includes software developed by the
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova * Apache Software Foundation (http://www.apache.org/)."
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova * Alternately, this acknowledgment may appear in the software itself,
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * if and wherever such third-party acknowledgments normally appear.
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova * 4. The names "Apache" and "Apache Software Foundation" must
d71bb9deea089887b4fd829c5b766e7e4de9f204Kristina Sojakova * not be used to endorse or promote products derived from this
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova * software without prior written permission. For written
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * permission, please contact apache@apache.org.
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * 5. Products derived from this software may not be called "Apache",
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * nor may "Apache" appear in their name, without prior written
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * permission of the Apache Software Foundation.
b43458b4d81f7451112cecbd757f3a05216e7088Kristina Sojakova * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova * SUCH DAMAGE.
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova * ====================================================================
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova * This software consists of voluntary contributions made by many
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova * individuals on behalf of the Apache Software Foundation. For more
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova * information on the Apache Software Foundation, please see
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova * Portions of this software are based upon public domain software
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova * originally written at the National Center for Supercomputing Applications,
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova * University of Illinois, Urbana-Champaign.
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova/* Some WWW schemes and their default ports; this is basically /etc/services */
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova/* This will become global when the protocol abstraction comes */
168d206b4e5fd436c98239a1b6629c651f54c8eeKristina Sojakova * A Web proxy module. Stages:
168d206b4e5fd436c98239a1b6629c651f54c8eeKristina Sojakova * translate_name: set filename to proxy:<URL>
168d206b4e5fd436c98239a1b6629c651f54c8eeKristina Sojakova * type_checker: set type to PROXY_MAGIC_TYPE if filename begins proxy:
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova * fix_ups: convert the URL stored in the filename to the
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova * canonical form.
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova * handler: handle proxy requests
b3bacd257ffcdd346b70ab690f03b28ad5f33fdcKristina Sojakova/* -------------------------------------------------------------- */
b3bacd257ffcdd346b70ab690f03b28ad5f33fdcKristina Sojakova/* Translate the URL into a 'filename' */
b3bacd257ffcdd346b70ab690f03b28ad5f33fdcKristina Sojakovastatic int alias_match(const char *uri, const char *alias_fakename)
b3bacd257ffcdd346b70ab690f03b28ad5f33fdcKristina Sojakova const char *end_fakename = alias_fakename + strlen(alias_fakename);
d71bb9deea089887b4fd829c5b766e7e4de9f204Kristina Sojakova const char *aliasp = alias_fakename, *urip = uri;
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova /* any number of '/' in the alias matches any number in
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova * the supplied URI, but there must be at least one...
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova /* Other characters are compared literally */
* GET http://othervhost/cgi-bin/printenv HTTP/1.0
return DECLINED;
int i, len;
if (r->proxyreq) {
return OK;
if (len > 0) {
return OK;
return DECLINED;
char *url, *p;
return DECLINED;
return HTTP_BAD_REQUEST;
char *nuri;
const char *ref;
return DECLINED;
&r->parsed_uri,
return HTTP_MOVED_PERMANENTLY;
const char *p2;
int i, rc;
int direct_connect = 0;
const char *maxfwd_str;
return DECLINED;
int access_status;
r->proxyreq = 0;
return OK;
return rc;
if (p == NULL)
return HTTP_BAD_REQUEST;
int has_m = 0;
if(imstr)
return HTTP_MOVED_PERMANENTLY;
int ii;
#if DEBUGGING
r->uri);
if (!direct_connect)
return rc;
return HTTP_FORBIDDEN;
return ps;
int port;
if (q != NULL) {
return NULL;
proxy_server_conf *psf = (proxy_server_conf *) ap_get_module_config(s->module_config, &proxy_module);
int found = 0;
if (!found) {
/*@@@FIXME: This copies only the first of (possibly many) IP addrs */ memcpy(&new->addr, hp.h_addr, sizeof(struct in_addr));
return NULL;
return NULL;
&proxy_module);
return NULL;
int found = 0;
if (!found) {
return NULL;
int *New;
return NULL;
int found = 0;
if (!found) {
#if DEBUGGING
#if DEBUGGING
#if DEBUGGING
#if DEBUGGING
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
{NULL}
{NULL}
static void register_hooks(void)