mod_proxy.c revision 5d392744e2077f71f34ce098ab49d2c0ddcf4ea3
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder/* Copyright 1999-2005 The Apache Software Foundation or its licensors, as
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * Licensed under the Apache License, Version 2.0 (the "License");
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * you may not use this file except in compliance with the License.
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * You may obtain a copy of the License at
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * http://www.apache.org/licenses/LICENSE-2.0
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * Unless required by applicable law or agreed to in writing, software
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * distributed under the License is distributed on an "AS IS" BASIS,
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * See the License for the specific language governing permissions and
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * limitations under the License.
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder#if (MODULE_MAGIC_NUMBER_MAJOR > 20020903)
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von SchroederAPR_DECLARE_OPTIONAL_FN(int, ssl_proxy_enable, (conn_rec *));
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von SchroederAPR_DECLARE_OPTIONAL_FN(int, ssl_engine_disable, (conn_rec *));
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von SchroederAPR_DECLARE_OPTIONAL_FN(int, ssl_is_https, (conn_rec *));
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von SchroederAPR_DECLARE_OPTIONAL_FN(char *, ssl_var_lookup,
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder#define MAX(x,y) ((x) >= (y) ? (x) : (y))
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * A Web proxy module. Stages:
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * translate_name: set filename to proxy:<URL>
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * map_to_storage: run proxy_walk (rather than directory_walk/file_walk)
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * can't trust directory_walk/file_walk since these are
fee6e355c164d9248e0512436812a476ad0c2e99Jonathan von Schroeder * not in our filesystem. Prevents mod_http from serving
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * the TRACE request we will set aside to handle later.
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * type_checker: set type to PROXY_MAGIC_TYPE if filename begins proxy:
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * fix_ups: convert the URL stored in the filename to the
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * canonical form.
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder * handler: handle proxy requests
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder/* -------------------------------------------------------------- */
880945fae9c3f61341f1cd94439c802b7a0af194Jonathan von Schroeder/* Translate the URL into a 'filename' */
#define PROXY_COPY_CONF_PARAMS(w, c) \
const char *key,
const char *val)
int ival;
if (ival < 0)
if (ival < 0)
if (ival < 0)
for (v = val; *v; v++) {
mode = 0;
if (mode)
if (mode)
if (mode)
if (ival == 0)
return NULL;
apr_pool_t *p,
const char *key,
const char *val)
int ival;
if (ival < 0)
if (provider) {
return NULL;
return NULL;
++aliasp;
++urip;
* GET http://othervhost/cgi-bin/printenv HTTP/1.0
: ap_default_port(r))))) {
return DECLINED;
int i, len;
if (r->proxyreq) {
return OK;
if (len > 0) {
return DECLINED;
return OK;
return DECLINED;
&proxy_module);
for (j = 0; j < num_sec; ++j)
if (entry_proxy->r
return OK;
int access_status;
return DECLINED;
return access_status;
return OK;
char *url, *p;
int access_status;
return DECLINED;
return access_status;
return HTTP_BAD_REQUEST;
char *nuri;
const char *ref;
return DECLINED;
&r->parsed_uri,
return HTTP_MOVED_PERMANENTLY;
const char *p2;
int direct_connect = 0;
const char *str;
long maxfwd;
return DECLINED;
switch (r->method_number) {
case M_TRACE: {
int access_status;
return OK;
case M_OPTIONS: {
int access_status;
return OK;
return HTTP_FORBIDDEN;
return HTTP_REQUEST_ENTITY_TOO_LARGE;
if (p == NULL) {
return HTTP_BAD_REQUEST;
return HTTP_MOVED_PERMANENTLY;
!direct_connect; i++) {
#if DEBUGGING
r->uri);
return access_status;
if (!worker)
goto cleanup;
if (!direct_connect) {
goto cleanup;
if (balancer)
if (balancer) {
goto cleanup;
if (balancer) {
return access_status;
return ps;
ps->allowed_connect_ports = apr_array_append(p, base->allowed_connect_ports, overrides->allowed_connect_ports);
ps->recv_buffer_size = (overrides->recv_buffer_size_set == 0) ? base->recv_buffer_size : overrides->recv_buffer_size;
ps->io_buffer_size = (overrides->io_buffer_size_set == 0) ? base->io_buffer_size : overrides->io_buffer_size;
ps->error_override = (overrides->error_override_set == 0) ? base->error_override : overrides->error_override;
ps->preserve_host = (overrides->preserve_host_set == 0) ? base->preserve_host : overrides->preserve_host;
ps->proxy_status = (overrides->proxy_status_set == 0) ? base->proxy_status : overrides->proxy_status;
return ps;
return (void *) new;
return new;
char *r, *f, *scheme;
int port;
if (regex)
scheme[p-r] = 0;
if (q != NULL) {
if (regex)
if (regex) {
if (!reg)
return NULL;
char *r = NULL;
char *word;
while (*arg) {
f = word;
r = word;
if (!val) {
if (r == NULL)
return NULL;
if (!balancer) {
conf, r);
if (err)
if (err)
if (!worker) {
if (err)
if (err)
return NULL;
if ( r == NULL)
return NULL;
return NULL;
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;
return NULL;
return NULL;
int timeout;
return NULL;
return NULL;
return NULL;
return NULL;
char *word;
while (*arg) {
if (!path)
else if (!name)
if (!val)
if (!path)
if (!name)
if (!worker) {
const char *err;
if (err)
if (!balancer) {
if (err)
return NULL;
const char *err;
if (!balancer) {
if (!worker) {
while (*arg) {
if (!val) {
if (worker)
if (err)
return NULL;
&proxy_module);
const char *errmsg;
return err;
if (!arg) {
return errmsg;
conf->r = r;
return NULL;
{NULL}
if (proxy_ssl_enable) {
if (proxy_ssl_disable) {
return proxy_ssl_disable(c);
if (proxy_is_https) {
return proxy_is_https(c);
const char *var)
if (proxy_ssl_val) {
return NULL;
return OK;
return OK;
++worker;
++balancer;
return OK;
worker++;
if (!reverse) {
s = s->next;
proxy_lb_workers = 0;
return OK;
request_rec *r,
request_rec *r,
(request_rec *r), (r),
(status, r),