[Zope] Zope w/ FastCGI / mod_rewrite

John Edstrom edstrom@Poopsie.hmsc.orst.edu
Wed, 16 Feb 2000 08:55:12 -0800 (PST)


Brian Takashi Hooper
> 
> Hi all,
> 
> I'm setting up Zope to use FastCGI w/ Apache, I followed the How-to by
> kedai on zope.org and got most of the way, however I still have a few
> questions:
> 
> 1. I want to serve my site with the root URL as FastCGI but be able to
> have absolute URLs sans hostname (i.e. <a href="/images/foo.gif">)
> resolve properly... if I just use a simple rewrite rule like:

From my experiences, I'd suggest that you go with with the
proxy/reverse-proxy/SiteAccess configuration unless you want to do
SSL.

> 
> ...
> RewriteRule ^/(.*) /fcgi/$1 [PT]
> 
> then the top page works, but all the links off this page are based off
> of <base href>, which gets set to something like http://myhost/fcgi.
> 
> Base href seems to be inferred by doing some stuff with the SERVER_URL
> and SCRIPT_NAME environment variables; SCRIPT_NAME gets passed from pcgi
> set to my FastCGI script name, /fcgi.  Is there a good way within the
> CGI protocol that I can tell Zope that it should ignore SCRIPT_NAME when
> deciding the base href of my site, since I'm rewriting the URL so that
> stuff without the /fcgi will get there?  
> 
> For now, I just added a hack to HTTPRequest.py, but as you can imagine,
> it's ugly :-(.  What's the RWTDT right way to do this?
> 

Look into the SiteAccess package.  I think it'll do most of what you
want. 

> 
> 2. I also would like to preserve ScriptAlias and Alias directories on
> the Apache side more nicely - right now it seems like if I line up some
> additional rewrite rules for /cgi-bin/, etc. before the fcgi rewrite
> rule, like:
> 
> RewriteRule ^/cgi-bin/(.*) /cgi-bin/$1 [L,PT]
> RewriteRule ^/(.*) /fcgi/$1 [PT]
> 
> the annoying thing is that sometimes URLs end up passing through the
> Rewrite engine twice as well  (explanation: a Pass-Through is necessary

Try :

RewriteRule ^/cgi-bin/.* - [L]

Essentially, this says do nothing and don't rewrite the url further.
I don't think that the passthrough is necessary if you aren't really
rewriting anything.  I've used this with aliased directories, but not
with script-aliased directories, so it may not work.  Another thing,
check your <DIRECTORY "/usr/.../cgi-bin/">...</DIRECTORY> directive to
make sure its proper.

> in order to get mod_alias to handle /cgi-bin as a ScriptAlias-ed
> directory; however, if there's any URL left at that point, i.e.
> /cgi-bin/myscript/foo/, then /foo/ travels through the Rewrite engine
> again, according to the logs).  This is more of an Apache question than
> a Zope question - however I think this is also of interest to others who
> might want to integrate Zope into their existing setup, so if anyone has
> any suggestions... :-) !
> 
> 
> Brian Hooper
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )
> 


-- 
 John Edstrom | edstrom @ slugo.hmsc.orst.edu

 http://bubo.hmsc.orst.edu/~edstrom
 "Lurker" at BioMOO (bioinfo.weizmann.ac.il:8888)

 Hatfield Marine Science Center
 2030 S. Marine Science Drive
 Newport, Oregon     97365-5296
 wk: (541) 867 0197
 fx: (541) 867 0138