Changing Apache configuration for each request

Changing Apache configuration for each request

am 12.08.2011 11:38:51 von Marcus Don

Hi

I'm trying to find a way to make certain Apache configuration directives
dynamic so they can be changed for each request. At first, I thought I could
do this with the Apache2::PerlSections module, but I've now realised all of
the examples in the documentation just make changes to the configuration
file at startup.

Please could someone confirm whether what I'm trying to do is possible with
mod_perl and, if it is, give some clues as to how?

Thanks

Marcus
--
Marcus Don
Senior Manager
Research and Development
DadaPro

Re: Changing Apache configuration for each request

am 12.08.2011 15:19:01 von torsten.foertsch

On Friday, 12 August 2011 11:38:51 Marcus Don wrote:
> Please could someone confirm whether what I'm trying to do is possible
> with mod_perl and, if it is, give some clues as to how?

see $r->add_config in Apache2::RequestUtil. Best place to do it is a=20
PerlMapToStorageHandler (or a PerlFixupHandler if that's not too late).
Note, however, that blocks and .htaccess files are applied by=20
the core maptostorage handler that runs after the modperl handler. You=20
can shortcut the core handler if your handler returns OK instead of=20
DECLINED. In that case your handler has to fill in $r->filename, $r-
>finfo and perhaps $r->path_info. blocks are applied just=20
after the maptostorage phase. They cannot be skipped.

Torsten Förtsch

=2D-=20
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

Re: Changing Apache configuration for each request

am 12.08.2011 15:55:46 von Marcus Don

Thank you so much Torston!

I had tried this before, but got this error message...

> Can't locate object method "add_config" via package "Apache2::RequestUtil=
"

....so I (incorrectly) concluded this function no longer existed and the
documentation was out-of-date. It seems the problem was actually just that =
I
was using the wrong handler!

Regards

Marcus

=20

> On Friday, 12 August 2011 11:38:51 Marcus Don wrote:
>> Please could someone confirm whether what I'm trying to do is possible
>> with mod_perl and, if it is, give some clues as to how?
>=20
> see $r->add_config in Apache2::RequestUtil. Best place to do it is a
> PerlMapToStorageHandler (or a PerlFixupHandler if that's not too late).
> Note, however, that blocks and .htaccess files are applied by
> the core maptostorage handler that runs after the modperl handler. You
> can shortcut the core handler if your handler returns OK instead of
> DECLINED. In that case your handler has to fill in $r->filename, $r-
>> finfo and perhaps $r->path_info. blocks are applied just
> after the maptostorage phase. They cannot be skipped.
>=20
> Torsten Förtsch

Re: Changing Apache configuration for each request

am 12.08.2011 16:45:53 von torsten.foertsch

On Friday, 12 August 2011 15:55:46 Marcus Don wrote:
> > Can't locate object method "add_config" via package
> > "Apache2::RequestUtil"

Did you "use Apache2::RequestUtil ();"? For a use case refer to=20
Apache2::Translation on CPAN.

Torsten Förtsch

=2D-=20
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

Re: Changing Apache configuration for each request

am 12.08.2011 17:34:21 von Marcus Don

>> Did you "use Apache2::RequestUtil ();"? For a use case refer to
>> Apache2::Translation on CPAN.

I did, but I was also trying to call the method statically. Forgive me if
this is stupid, it's been many years since I've used Perl.

What I'm actually doing is creating a proof of concept configuration for a
mass hosting platform using suexec, chroot and PHP fastcgi. Thanks to your
help, it is now working. Currently, I'm using PerlTransHandler to map the
host name of the request to a filesystem path, which I'm storing in an
environment variable. Then, in PerlMapToStorageHandler I am writing the
FCGIWrapper configuration directive.

The only "problem" at the moment is that I'm currently depending on
mod_userdir to do the suexec bit, which means I have to place the PHP
wrapper script inside the document root. This isn't technically a problem,
but I'd rather place it somewhere else in the chroot jail where an
uneducated user would be less likely to modify or delete it. I've tried
setting User and Group myself instead, but I'm having trouble understanding
Apache's security model in this context. I've just ordered a copy of the
O'Reilly book on the subject, but any pointers you could give me would be
much appreciated :)

Regards

Marcus