[Twisted-web] Nevow and distrib

Matt Goodall matt at pollenation.net
Mon Jul 12 03:51:18 MDT 2004


On Mon, 2004-07-12 at 06:21, David Reid wrote:
> Much more interesting, is the new-web/twisted/web/proxy.py which moshez
> rewrote to allow support of both TCP and Unix sockets.
> In a much cleaner way than my distrib.py hackery.

Yes, that does look good. However, there's nothing which tells the Nevow
app what URL it is actually working behind which means generated URLs
are incorrect. Now, if proxy also set the 'x-forwarded-from' header then
the Nevow app would work just the same. Hmm, it records 'host' in the
request headers ... perhaps that's supposed to include the port too?

Anyway, thanks for mentioning this.

Cheers, Matt

> 
> -David
> 
> On Sun, 2004-07-11 at 20:01, Matt Goodall wrote:
> > Hi all,
> > 
> > Attached is a distrib module and a patch to nevow/appserver.py that
> > allows Nevow to work behind a distrib server. Yippee! I claim no credit
> > for the distrib module, I ripped it from new-web. The change to
> > appserver.py is almost certainly not robust enough but ti works for a
> > simple distrib server. Patches will be most welcome as you fix the
> > bugs ;-).
> > 
> > You don't need a Publisher with this as it's all proxy based. I imagine
> > the proxy will work over a UNIX socket but I only tested over TCP. Below
> > is the server I used to test:
> > 
> > from twisted.application import service
> > from twisted.application import internet
> > from nevow import appserver, distrib
> > 
> > application = service.Application('distribtest')
> > internet.TCPServer(
> >     8000,
> >     appserver.NevowSite(
> >         distrib.ResourceSubscription('localhost', 8001)
> >     )
> > ).setServiceParent(application)
> > 
> > Also, I imagine it's relatively easy to use the same technique to hide a
> > Nevow app behind Apache. It's just a matter of adding a 'x-forwarded-
> > from' header to the request before proxying it to the twistd server (see
> > distrib.py). mod_proxy + mod_headers should help, maybe mod_rewrite too.
> > 
> > Hope this is of interest.
> > 
> > Cheers, Matt
> > 
> 
> ______________________________________________________________________
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
-- 
     __
    /  \__     Matt Goodall, Pollenation Internet Ltd
    \__/  \    w: http://www.pollenation.net
  __/  \__/    e: matt at pollenation.net
 /  \__/  \    t: +44 (0)113 2252500
 \__/  \__/
 /  \          Any views expressed are my own and do not necessarily
 \__/          reflect the views of my employer.




More information about the Twisted-web mailing list