My apologies if this question has been answered before, but I couldn't figure it out from available documentation or list archives. I run a server for some student groups off a machine in my dorm and I'm teaching myself Zope (slowly). I deal with the dynamic IP address by using several *.penguinpowered.com domains. I would like to set up one or more virtual hosts such that http://host1.penguinpowered.com/ points to some folder in the Zope database. It seems this is possible using Set Access Rule and SiteRoot objects, but how? Any help is appreciated. I am now using plain zserver 2.1.6. -------------- Building highways to reduce traffic is like loosening your belt to reduce obesity.
Alex Gould wrote:
My apologies if this question has been answered before, but I couldn't figure it out from available documentation or list archives.
I run a server for some student groups off a machine in my dorm and I'm teaching myself Zope (slowly). I deal with the dynamic IP address by using several *.penguinpowered.com domains. I would like to set up one or more virtual hosts such that http://host1.penguinpowered.com/ points to some folder in the Zope database. It seems this is possible using Set Access Rule and SiteRoot objects, but how? Any help is appreciated. I am now using plain zserver 2.1.6.
I have answered this before :) This is the access rule I use to match subdomains with a folder that has the same name as the subdomain: Get subdomain: <dtml-let hostname="_.string.join(_.string.split(_.string.split(HTTP_HOST, ':')[0], '.')[0], '')"> Is there a folder named as this subdomain? <dtml-try> <dtml-if "_[hostname]"> Set logical root: <dtml-call "REQUEST.set('SiteRootPATH', '/')"> Add physical root: <dtml-call "REQUEST.path.append(hostname)"> </dtml-if> <dtml-except KeyError> <dtml-call "RESPONSE.redirect('http://penguinpowered.com/NoHostHere')"> </dtml-try> </dtml-let> Then there has to be a site root in each folder, where the path and base are *empty*. Hope that helps, ethan mindlace fremen Zopatista Community Liason
"emf" == ethan mindlace fremen <mindlace@digicool.com> writes:
emf> Set logical root: <dtml-call "REQUEST.set('SiteRootPATH', '/')"> emf> Add physicalroot: <dtml-call "REQUEST.path.append(hostname)"> As far as I can see, with this setup it is not possible to determine from Z2.log which virtual host has served a request. Is there a way to make the host logged as well? Rob Hooft -- ===== rob@hooft.net http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! =========
On Tue, 13 Jun 2000, ethan mindlace fremen wrote:
<dtml-let hostname="_.string.join(_.string.split(_.string.split(HTTP_HOST, ':')[0], '.')[0], '')"> <dtml-try> <dtml-if "_[hostname]"> Set logical root: <dtml-call "REQUEST.set('SiteRootPATH', '/')"> Add physical root: <dtml-call "REQUEST.path.append(hostname)"> </dtml-if> <dtml-except KeyError> <dtml-call "RESPONSE.redirect('http://penguinpowered.com/NoHostHere')"> </dtml-try> </dtml-let>
This almost works, but then even the superuser can't access these folders (unauthorized)! Help! --------------- Building highways to reduce traffic is like loosening your belt to reduce obesity
Alexander N Gould wrote:
On Tue, 13 Jun 2000, ethan mindlace fremen wrote:
<dtml-let hostname="_.string.join(_.string.split(_.string.split(HTTP_HOST, ':')[0], '.')[0], '')"> <dtml-try> <dtml-if "_[hostname]"> Set logical root: <dtml-call "REQUEST.set('SiteRootPATH', '/')"> Add physical root: <dtml-call "REQUEST.path.append(hostname)"> </dtml-if> <dtml-except KeyError> <dtml-call "RESPONSE.redirect('http://penguinpowered.com/NoHostHere')"> </dtml-try> </dtml-let>
This almost works, but then even the superuser can't access these folders (unauthorized)! Help!
Hmm. superuser can't manage the folders? They should be able to. I assume you mean by "almost works" it doesn't let you manage? First, you can always disable siteaccess by using __no_before_traverse__ as the first item in the path. Second, once you set this up, you cannot manage the folder except from it's url ( host1.penguinpowered.com/manage should work) These are kind of stabs in the dark. If you could show me some urls that don't work, then maybe I can do some more. Thanks, ~ethan
On Wed, 14 Jun 2000, ethan mindlace fremen wrote:
Hmm. superuser can't manage the folders? They should be able to. I assume you mean by "almost works" it doesn't let you manage?
<snip>
Second, once you set this up, you cannot manage the folder except from it's url ( host1.penguinpowered.com/manage should work)
These are kind of stabs in the dark. If you could show me some urls that don't work, then maybe I can do some more.
No, even worse! Here's what I do, and what happens: Add folders with the names of the subdomains. Add SiteRoots to each of these folders, with both fields blank as instructed. Create a dtml-method at the root level named "virtualhosts" using the script you provided. Add a Site Access Rule at the root level linked to the method. ... everything works fine up to here. A confirmation message appears saying "You have added a site access rule" or something like that. Then when I click on "OK", a dialog comes up saying "Authorization failed, retry?". Even the superuser doesn't work. I try quitting the browser (Netscape) and accessing the site (using any of the urls - masspirg.penguinpowered.com, singlepayermass.penguinpowered.com, others), but the exact same error occurs. Here is the traceback: Traceback (innermost last): File /usr/lib/python1.5/site-packages/ZPublisher/Publish.py, line 214, in publish_module File /usr/lib/python1.5/site-packages/ZPublisher/Publish.py, line 179, in publish File /usr/lib/python1.5/site-packages/ZPublisher/Publish.py, line 151, in publish File /usr/share/zope/lib/python/Products/SiteAccess/ChangeBehaviors.py, line 93, in traverse File /usr/share/zope/lib/python/Products/SiteAccess/ChangeBehaviors.py, line 27, in before_traverse File /usr/share/zope/lib/python/OFS/DTMLMethod.py, line 150, in __call__ (Object: virtualhosts) File /usr/lib/python1.5/site-packages/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: virtualhosts) File /usr/lib/python1.5/site-packages/DocumentTemplate/DT_Let.py, line 145, in render (Object: hostname="_.string.join(_.string.split(_.string.split(HTTP_HOST,':')[0], '.')[0], '')") File /usr/lib/python1.5/site-packages/DocumentTemplate/DT_Try.py, line 212, in render File /usr/lib/python1.5/site-packages/DocumentTemplate/DT_Try.py, line 221, in render_try_except File /usr/lib/python1.5/site-packages/DocumentTemplate/DT_Util.py, line 335, in eval (Object: _[hostname]) (Info: _) File <string>, line 0, in ? File /usr/lib/python1.5/site-packages/DocumentTemplate/DT_Util.py, line 161, in careful_getitem Unauthorized: (see above) Let me clarify some relevant things about my setup. My server is in my dorm room, thus is allocated a dynamic IP address through DHCP, also a random hostname (prin-###.res.umass.edu). I get around this by registering some names with penguinpowered.com "dynamic DNS" and automatically updating them with my IP address when it changes. Before I tried this virtual hosts experiment, the system worked just fine - everyone who tested it could reach masspirg.penguinpowered.com. I'm teaching myself this server/content management stuff during this summer as I work on a groupware-like site that will eventually be moved to a dedicated server with a better connection. Thanks for all your help - I'm sure you have much more important things to do than assisting newbies like myself! --------------------- Building highways to reduce traffic is like loosening your belt to reduce obesity
Never mind the last message. A typo in the vhosts dtml method was the culprit, combined with my near total ignorance of Python which prevented me from spotting it. Change line 5 from <dtml-if "_[hostname]"> to <dtml-if "[hostname]"> That does it! Thanks! -------------- Building highways to reduce traffic is like loosening your belt to reduce obesity
participants (4)
-
Alex Gould -
Alexander N Gould -
ethan mindlace fremen -
rob@hooft.net