You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Philip Mak <pm...@aaanime.net> on 2001/11/09 13:10:22 UTC

ProxyPass and DirectoryIndex

On port 80, I'm running a non-mod_perl httpd.
On port 8001, I'm running a mod_perl httpd.

Port 80 is ProxyPassing to port 8001 like this:
RewriteRule ^/(.+)\.asp$ http://127.0.0.1:8001/$1.asp [p]

The httpds have different DocumentRoots however, so if I visit
http://mysite.com/ it will return a directory index rather than calling
the index.asp file.

My current solution is to "touch index.asp" in the port 80 DocumentRoot
and have "DirectoryIndex index.asp" so that it knows to ProxyPass those
requests. I'd have to "touch index.asp" manually for every directory,
though. Is there a better way around this?


Re: ProxyPass and DirectoryIndex

Posted by Mohit Agarwal <mo...@foc.demonhosting.co.uk>.
On Fri, 9 Nov 2001, Jorge Godoy wrote:

> Philip Mak <pm...@aaanime.net> writes:
> 
> > My current solution is to "touch index.asp" in the port 80 DocumentRoot
> > and have "DirectoryIndex index.asp" so that it knows to ProxyPass those
> > requests. I'd have to "touch index.asp" manually for every directory,
> > though. Is there a better way around this?
> 
> To ease your task... I think there might be a better solution that
> does not involve this index.asp file, but I can't think of it now.
> 
> 
> ======================================================================
> #!/bin/bash
> cd document_root
> for i in `find -type d`
> do
>   cd $i
>   touch index.asp
>   cd -
> done
> ======================================================================

If this is the only way then you don't need such a huge script.  One line
will do:

   find document_root -type d -exec touch \{\}/index.asp \;


Re: ProxyPass and DirectoryIndex

Posted by Jorge Godoy <go...@conectiva.com>.
Philip Mak <pm...@aaanime.net> writes:

> My current solution is to "touch index.asp" in the port 80 DocumentRoot
> and have "DirectoryIndex index.asp" so that it knows to ProxyPass those
> requests. I'd have to "touch index.asp" manually for every directory,
> though. Is there a better way around this?

To ease your task... I think there might be a better solution that
does not involve this index.asp file, but I can't think of it now.


======================================================================
#!/bin/bash
cd document_root
for i in `find -type d`
do
  cd $i
  touch index.asp
  cd -
done
======================================================================


See you,
-- 
Godoy. <go...@conectiva.com>

Solutions Developer       - Conectiva Inc. - http://en.conectiva.com
Desenvolvedor de Soluções - Conectiva S.A. - http://www.conectiva.com.br

Re: Re: ProxyPass and DirectoryIndex

Posted by Andy Turner <tu...@mikomi.org>.
On Fri, Nov 09, 2001 at 02:17:44PM -0500, Philip Mak wrote:
> > RewriteRule ^(.*)/$	http://127.0.0.1:8001$1/index.asp [p]
> 
> That looks like it will ProxyPass every directory to the mod_perl enabled
> httpd. It would make index.html not work anymore, though. I think the
> optimal solution would:
> 
> - display index.html if it is present in the non-mod_perl web directory
> - else display index.asp if it is present in the mod_perl web directory
> - else display a directory listing (if Options +Indexes is on)
> 
> I'm thinking that this is not possible, at least not without having to
> make some really ugly configuration hack?

How about this:

<Directory /path/to/static/files/>
RewriteCond    %{REQUEST_FILENAME} -d
RewriteCond    %{REQUEST_FILENAME}index.html    !-f
RewriteCond    /path/to/dynamic/files%{REQUEST_URI}/index.asp -f
RewriteRule    ^(.*)$      http://127.0.0.1:8001$1/index.asp   [P]
</Directory>

-- 
Andy <tu...@mikomi.org> - http://anime.mikomi.org/ - Community Anime Reviews
  And the moral of this message is...
    To a Californian, all New Yorkers are cold; even in heat they rarely go
    above fifty-eight degrees.  If you collapse on a street in New York, plan
    to spend a few days there.
    	-- From "East vs. West: The War Between the Coasts

Re: ProxyPass and DirectoryIndex

Posted by Igor Sysoev <is...@rambler-co.ru>.
On Fri, 9 Nov 2001, Balazs Rauznitz wrote:

> On Fri, 9 Nov 2001, Philip Mak wrote:
> 
> > On port 80, I'm running a non-mod_perl httpd.
> > On port 8001, I'm running a mod_perl httpd.
> > 
> > Port 80 is ProxyPassing to port 8001 like this:
> > RewriteRule ^/(.+)\.asp$ http://127.0.0.1:8001/$1.asp [p]
> > 
> > The httpds have different DocumentRoots however, so if I visit
> > http://mysite.com/ it will return a directory index rather than calling
> > the index.asp file.
> > 
> > My current solution is to "touch index.asp" in the port 80 DocumentRoot
> > and have "DirectoryIndex index.asp" so that it knows to ProxyPass those
> > requests. I'd have to "touch index.asp" manually for every directory,
> > though. Is there a better way around this?
> 
> How about:
> 
> RewriteRule ^(.*)/$	http://127.0.0.1:8001$1/index.asp [p]

In any case you need to double directory hierachy to allow mod_dir
handle redirects from "/dir" to "/dir/". Even without touching index.asp.

Igor Sysoev


Re: ProxyPass and DirectoryIndex

Posted by Igor Sysoev <is...@rambler-co.ru>.
On Fri, 9 Nov 2001, Philip Mak wrote:

> > You can try with my mod_accel:
> > ftp://ftp.lexa.ru/pub/apache-rus/contrib/mod_accel-1.0.6.tar.gz
> >
> > AccelCacheRoot  cache
> > AccelNoCache    on
> > AccelPass       /          http://127.0.0.1:8081/
> > AccelNoPass     ~*\.jpg$   ~*\.gif$
> 
> Hmm, so that would pass any URL that doesn't end in .jpg or .gif. While
> not semantically equivalent to what I'm doing, I think it would actually
> work for my case (I just have to specify what extensions NOT to pass).

You can specify not only extension but any Apache regexp or location:

AccelNoPass     /some_static_location
AccelNoPass     /download  ~*\.jpg$   ~*\.gif$

'*' after '~' means case-insensitive regexp.
'~\.jpg$' is case-sensitive regexp.
 
Also with mod_accel you will have other benefits -
it allows to make a real backend buffering, 
to use busy locks and to limit connections to backend.

Igor Sysoev


Re: ProxyPass and DirectoryIndex

Posted by Philip Mak <pm...@aaanime.net>.
> > My current solution is to "touch index.asp" in the port 80 DocumentRoot
> > and have "DirectoryIndex index.asp" so that it knows to ProxyPass those
> > requests. I'd have to "touch index.asp" manually for every directory,
> > though. Is there a better way around this?

> RewriteRule ^/$ http://127.0.0.1:8001/ [p]

That would only pass the main directory; it won't take care of this
problem for the subdirectories.

> Why do you use RewriteRule instead of ProxyPass ?
> ProxyPass    /    http://127.0.0.1:8081/
> Or do you have static files that you don't want to pass to mod_perl ?

I have static files that I don't want to pass to mod_perl.

> RewriteRule ^(.*)/$	http://127.0.0.1:8001$1/index.asp [p]

That looks like it will ProxyPass every directory to the mod_perl enabled
httpd. It would make index.html not work anymore, though. I think the
optimal solution would:

- display index.html if it is present in the non-mod_perl web directory
- else display index.asp if it is present in the mod_perl web directory
- else display a directory listing (if Options +Indexes is on)

I'm thinking that this is not possible, at least not without having to
make some really ugly configuration hack?

> You can try with my mod_accel:
> ftp://ftp.lexa.ru/pub/apache-rus/contrib/mod_accel-1.0.6.tar.gz
>
> AccelCacheRoot  cache
> AccelNoCache    on
> AccelPass       /          http://127.0.0.1:8081/
> AccelNoPass     ~*\.jpg$   ~*\.gif$

Hmm, so that would pass any URL that doesn't end in .jpg or .gif. While
not semantically equivalent to what I'm doing, I think it would actually
work for my case (I just have to specify what extensions NOT to pass).


Re: ProxyPass and DirectoryIndex

Posted by Balazs Rauznitz <ba...@commissioner.com>.
On Fri, 9 Nov 2001, Philip Mak wrote:

> On port 80, I'm running a non-mod_perl httpd.
> On port 8001, I'm running a mod_perl httpd.
> 
> Port 80 is ProxyPassing to port 8001 like this:
> RewriteRule ^/(.+)\.asp$ http://127.0.0.1:8001/$1.asp [p]
> 
> The httpds have different DocumentRoots however, so if I visit
> http://mysite.com/ it will return a directory index rather than calling
> the index.asp file.
> 
> My current solution is to "touch index.asp" in the port 80 DocumentRoot
> and have "DirectoryIndex index.asp" so that it knows to ProxyPass those
> requests. I'd have to "touch index.asp" manually for every directory,
> though. Is there a better way around this?

How about:

RewriteRule ^(.*)/$	http://127.0.0.1:8001$1/index.asp [p]

-Balazs


Re: ProxyPass and DirectoryIndex

Posted by Igor Sysoev <is...@rambler-co.ru>.
On Fri, 9 Nov 2001, Philip Mak wrote:

> On port 80, I'm running a non-mod_perl httpd.
> On port 8001, I'm running a mod_perl httpd.
> 
> Port 80 is ProxyPassing to port 8001 like this:
> RewriteRule ^/(.+)\.asp$ http://127.0.0.1:8001/$1.asp [p]
> 
> The httpds have different DocumentRoots however, so if I visit
> http://mysite.com/ it will return a directory index rather than calling
> the index.asp file.
> 
> My current solution is to "touch index.asp" in the port 80 DocumentRoot
> and have "DirectoryIndex index.asp" so that it knows to ProxyPass those
> requests. I'd have to "touch index.asp" manually for every directory,
> though. Is there a better way around this?

Why do you use RewriteRule instead of ProxyPass ?

ProxyPass    /    http://127.0.0.1:8081/

Or do you have static files that you don't want to pass to mod_perl ?

You can try with my mod_accel:
ftp://ftp.lexa.ru/pub/apache-rus/contrib/mod_accel-1.0.6.tar.gz
It's replacement of mod_proxy. Documentation in Russian only.
But you configuration is simple and can be following:

AccelCacheRoot  cache
AccelNoCache    on
AccelPass       /          http://127.0.0.1:8081/
AccelNoPass     ~*\.jpg$   ~*\.gif$

It's Unix only. It can probably run on Win32 under CygWin -
but I didn't try it.

Igor Sysoev