httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@ast.cam.ac.uk (David Robinson)
Subject Re: The List
Date Tue, 16 Jan 1996 17:13:00 GMT
>Oh, and toss a proxy module onto the pile somewhere. I'm almost done with
>one *grin*. By next weekend, I should have a working version you can all
>play with, though I make no gaurantees. 

I don't know what you've done, but I've settled the changes I needed to
make to the 1.0 core to support a proxy module. Of course, this will
need re-writing for 1.1.

The changes are:
make http_protocol.c:read_request() proxy-aware; this is limited to setting a
new request_rec 'proxyreq' element, and not URL decoding or removing ".."
from the URL for proxy requests.

To handled the request, I've slightly hacked http_request.c. The 'hack'
is to treat filenames not beginning with '/' as 'server-internal'.

Thus the proxy module translates the request
scheme://foo.bar/data to the 'file' proxy:scheme://foo.bar/data

This enables protection of the proxy server, with, e.g.
<Directory proxy:*>
<Limit GET POST>
order deny,allow
deny from all
allow from 131.111.69.
</Limit>

And also
Alias /proxy proxy:http://otherserver

means that local URLs like /proxy/foobar will picked up by the proxy
module.

At first I thought this was all a bit hacky, but I'm becoming enamoured of
this. I think it could be usefully incorporated into 1.1; the optimal
design would miss out the PROXY_MAGIC_TYPE part (which really _is_ a hack);
instead the core would directly invoke module <foobar> for filenames beginning
<foobar>:

 David.

[A cookie to anyone who can understand what I'm talking about]

prototype 1.0 mod_proxy:

static int
proxy_trans(request_rec *r)
{
    if (!r->proxyreq) return DECLINED;
    
    r->filename = pstrcat(r->pool, "proxy:", r->uri, NULL);
    return OK;
}

static int
proxy_type(request_rec *r)
{
    if (strncmp(r->filename, "proxy:", 6) == 0)
    {
	r->content_type = PROXY_MAGIC_TYPE;
	return OK;
    } else
	return DECLINED;
}

static int
proxy_handler(request_rec *r)
{
    const char *url;
    if (strncmp(r->filename, "proxy:", 6) != 0) return DECLINED;

/*   ... handle the request here */
}
 
static handler_rec proxy_handlers[] = {
{ PROXY_MAGIC_TYPE, proxy_handler },
{ NULL }
};


module proxy_module = {
   STANDARD_MODULE_STUFF,
   NULL,			/* initializer */
   NULL,			/* create per-directory config structure */
   NULL,			/* merge per-directory config structures */
   NULL,			/* create per-server config structure */
   NULL,			/* merge per-server config structures */
   NULL,			/* command table */
   proxy_handlers,	        /* handlers */
   proxy_trans,			/* translate_handler */
   NULL,			/* check_user_id */
   NULL,			/* check auth */
   NULL,			/* check access */
   proxy_type,			/* type_checker */
   NULL,			/* pre-run fixups */
   NULL				/* logger */
};

Mime
View raw message