[Zope-CMF] Getting a portal folder as Root
Martijn Pieters
mj@digicool.com
Thu, 19 Apr 2001 16:08:57 +0200
--BOKacYhQ+x31HxR3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Thu, Apr 19, 2001 at 01:17:45PM +0200, Gitte Wange wrote:
> On 19 Apr 2001 12:46:19 +0100, seb bacon wrote:
> > SiteAccess really is what you need, although i must admit i've never
> > really got to the bottom of it. but i've got it doing exactly what
> > you need already. read the info page:
> >
> > http://www.zope.org/Members/4am/SiteAccess2/info
> >
> > VirtualSiteMonster does the same thing in a different way, but there's
> > less docs for it.
> >
> > seb
>
> Maybe I don't get it - but to me it looks like this product is used with
> Apache ?
>
> I would try to avoid this if it is possible
No, you can also use an Access Rule to manipulate the traversal stack
(which VHM uses to reset the paths).
I attached the Python Script that I use as an access rule for my server;
it makes sure that URLs coming through stunnel (HTTPS SSL encryption) are
correct, redirects /manage access to the HTTPS port, and rewrites URLs for
my virtal domains.
--
Martijn Pieters
| Software Engineer mailto:mj@digicool.com
| Digital Creations http://www.digicool.com/
| Creators of Zope http://www.zope.org/
---------------------------------------------
--BOKacYhQ+x31HxR3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=AccessRule
## Script (Python) "AccessRule"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=
##title=Rewrite virtual host URLs to use the VHM; manage stunnel HTTPS protocol
##
req = context.REQUEST
resps = req.RESPONSE
stack = req['TraversalRequestNameStack']
# Manage HTTPS protocol (via stunnel)
if req['REMOTE_ADDR'] == '127.0.0.10': # Special stunnel connection ip
prot = 'https'
else:
prot = 'http'
# /manage URLs *must* be accessed through https
if prot == 'http' and len(stack) > 0:
if (
stack[-1][:6] == 'manage' or
stack[-1][:13] == 'ZPythonScript' or
stack[-1][:9] == 'ZBindings'
):
# Note that req.URL isn't formed yet; we are just starting the traverse.
url = 'https:%s%s' % (req['BASE0'][5:], req['PATH_TRANSLATED'])
if req['QUERY_STRING']:
url = '%s?%s' % (url, req['QUERY_STRING'])
raise 'Redirect', url
# Manage Virtual Hosts
if req.has_key('HTTP_HOST'):
host = req['HTTP_HOST']
else:
host = 'www.zopatista.com' # Default host name
port = req['SERVER_PORT']
if port != '80':
host = '%s:%s' % (host, port)
# The default host comes from the root Folder
vhost_folder = []
# The mjpieters.* domain comes from the vhosts/mjpieters Folder
if host[-13:] in ('mjpieters.com', 'mjpieters.org', 'mjpieters.net'):
vhost_folder = ['vhosts', 'mjpieters']
if vhost_folder:
# Reverse path
vhost_folder.reverse()
# Extend the stack with VH info
stack.extend(['VirtualHostRoot'])
stack.extend(vhost_folder)
# Extend the stack to include host information and marker
stack.extend([host, prot, 'VirtualHostBase'])
--BOKacYhQ+x31HxR3--