httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Graham Dumpleton" <>
Subject Re: Question: how to change the request in input filter and pass it to proxy
Date Thu, 03 Apr 2008 04:39:41 GMT
On 03/04/2008, Olexandr Prokhorenko <> wrote:
> Hi everyone,
>  I am working on the input filter which is going to catch on input requests,
>  find the bucket with "Host: ", modify it and pass it through.  I will modify
>  it to something that does not belong to my httpd server, so I need to pass
>  it through the proxy module (my guess ;).  I can't use either the static
>  ProxyPass or ProxyReversePass, because the host will be modified dynamically
>  and it will depend on what is called and substitute it from the database
>  call.
>  It wasn't a big deal to catch on the Host: (well, I may also need to look
>  for something like GET, but this is not the highest
>  priority now).  I have created a new HEAP bucket, put it instead of an
>  original one, however, a) it looks to me that Apache makes a call and gives
>  an error saying file wasn't found, however the Web page displayed is the
>  correct one, like not being rewritten, and the httpd child crashes; and b) I
>  need to send it to proxy somehow and pass the call to it.
>  I am not very good on concept, my book on Apache modules is still on the
>  way, but I'd very appreciate any hints on this.
>  Thank you.  I'd very thankful for cc: me as well.

I think you may perhaps be going about this the wrong way. One can
cause a request to be proxied by doing something like the following.
This example uses mod_python, but could be done in C code or mod_perl
as well.

import posixpath

from mod_python import apache

def fixuphandler(req):

  if req.proxyreq:
    return apache.DECLINED

  normalised_uri = posixpath.normpath(req.uri)

  if normalised_uri:
    if normalised_uri != '/' and req.uri[-1] == '/':
      normalised_uri += '/'

  length = len(req.filename)
  length -= len( - 1
  length += len(req.path_info or '')

  baseurl = normalised_uri[:-length]
  path = normalised_uri[len(baseurl):]


  req.proxyreq = apache.PROXYREQ_REVERSE
  req.uri = '' + path
  req.filename = 'proxy:%s' % req.uri
  req.handler = 'proxy-server'

  return apache.OK

If you didn't want to proxy a particular request, just return DECLINED
when you know so.


View raw message