You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Richard L. Goerwitz" <ri...@catlin.cis.brown.edu> on 2000/06/12 17:10:01 UTC

mod_perl: Configuration info at run-time

It's not obvious to me how one might get a list of VirtualHosts that are
configured for the current server instance (at run-time, e.g., from in-
side a Perl module).

Is there some canonical way to do this?

-- 
Richard Goerwitz				Richard_Goerwitz@Brown.EDU

Re: mod-perl and redhat 6.2 's apache rpm

Posted by Ged Haywood <ge...@jubileegroup.co.uk>.
Hi there,

On Mon, 12 Jun 2000, Clayton Cottingham aka DrFrog wrote:

> is there something seriously wrong with redhats
> apache and modperl rpms?

Yup.

> am i gonna have to recompile apache myself?

Yup.

73,
Ged.



mod-perl and redhat 6.2 's apache rpm

Posted by Clayton Cottingham aka DrFrog <dr...@smartt.com>.
is there something seriously wrong with redhats
apache and modperl rpms?

ive just tried for an hour to get the Pg perl module to load at startup
{through the startup.pl way}
and it just crashes without any errors

whats the deal ? am i gonna have to recompile apache myself?

Re: Caching and mod_perl

Posted by Perrin Harkins <pe...@primenet.com>.
On Mon, 12 Jun 2000, Richard L. Goerwitz wrote:

> What I'm interested in knowing is whether anybody's written an inter-
> face to the actual Apache caching utility routines.

If it's not in the Eagle book, the answer is most likely "no".  Most of
use dbm files or something similar for caching from mod_perl.

- Perrin


Re: Caching and mod_perl

Posted by "Richard L. Goerwitz" <ri...@catlin.cis.brown.edu>.
Regarding my question about mod_perl access to Apache caching utilities,
morpheus@cinemaspace.berkeley.edu wrote:

> See page 120 in the Eagle book for If-Modified-Since caching, using
> update_mtime and set_last_modified.  Except for the creation of temp
> files and unlinking, this is somewhat similar to what
> ap_proxy_cache_update is doing in mod_proxy.

Maybe I read that chapter all wrong, but I thought the problem to be
solved there was that of providing clients with enough information to
effectively cache what, in fact, was a dynamically generated navigation
bar.

What I'm interested in knowing is whether anybody's written an inter-
face to the actual Apache caching utility routines.

-- 
Richard Goerwitz				Richard_Goerwitz@Brown.EDU

Re: Caching and mod_perl

Posted by mo...@cinemaspace.berkeley.edu.
See page 120 in the Eagle book for If-Modified-Since caching, using
update_mtime and set_last_modified.  Except for the creation of temp
files and unlinking, this is somewhat similar to what 
ap_proxy_cache_update is doing in mod_proxy.

~m

On Mon, 12 Jun 2000, Richard L. Goerwitz wrote:

> Is there a mod_perl interface to caching routines available via the C
> api (e.g., mod_proxy's ap_proxy_cache_update()--or to any other low-
> level caching utilities)?
> 
> -- 
> Richard Goerwitz				Richard_Goerwitz@Brown.EDU
> 


Caching and mod_perl

Posted by "Richard L. Goerwitz" <ri...@catlin.cis.brown.edu>.
Is there a mod_perl interface to caching routines available via the C
api (e.g., mod_proxy's ap_proxy_cache_update()--or to any other low-
level caching utilities)?

-- 
Richard Goerwitz				Richard_Goerwitz@Brown.EDU

Re: mod_perl: Configuration info at run-time

Posted by "J. J. Horner" <jh...@2jnetworks.com>.
On Mon, 12 Jun 2000, Richard L. Goerwitz wrote:

> It's not obvious to me how one might get a list of VirtualHosts that are
> configured for the current server instance (at run-time, e.g., from in-
> side a Perl module).
> 
> Is there some canonical way to do this?
> 

I would guess that you could do a DNS lookup on your webserver IPs and get
all the CNAMEs associated with it.  But this is just a thought.

JJ

-- 
J. J. Horner
Apache, Perl, Unix, Linux
jhorner@knoxlug.org http://www.knoxlug.org/


Re: mod_perl: Configuration info at run-time

Posted by "Richard L. Goerwitz" <ri...@catlin.cis.brown.edu>.
Matt Sergeant wrote:

> > > for ($s = Apache->server; $s; $s = $s->next) {
> > >         my ($server, $port) = ($s->server_hostname, $s->port);
> > >         $r->print('server: ', $server, "\n");
> > >         $r->print('port: ', $port, "\n");
> > >
> > >         my $subreq = $r->lookup_uri("http://$server:$port/");
> > >         $r->print('variable value: ', $subreq->dir_config('SomePerlVariable'), "\n");
> > > }

> Why don't you just try it? It should work regardless. The auth stuff
> should only happen if you actually call $subreq->run()

Thanks for that pointer re subreqs and auth.  I appreciate it.

For whatever reason, when I try this, though, dir_config() doesn't pick
up any of my Perl variables, even though it (naturally) has no trouble
doing this when called in the usual way (e.g., $r->dir_config()).

My configuration is pretty vanilla:  RedHat 6.1 w/ from-scratch builds
of Perl 5.00503, Apache 1.3.12, mod_perl 1.24.

-- 
Richard Goerwitz				Richard_Goerwitz@Brown.EDU

Re: mod_perl: Configuration info at run-time

Posted by Matt Sergeant <ma...@sergeant.org>.
On Tue, 13 Jun 2000, Richard L. Goerwitz wrote:

> Matt Sergeant wrote:
> 
> > OK then, try this:
> > 
> > for ($s = Apache->server; $s; $s = $s->next) {
> >         my ($server, $port) = ($s->server_hostname, $s->port);
> >         $r->print('server: ', $server, "\n");
> >         $r->print('port: ', $port, "\n");
> > 
> >         my $subreq = $r->lookup_uri("http://$server:$port/");
> >         $r->print('variable value: ', $subreq->dir_config('SomePerlVariable'), "\n");
> > }
> 
> Ah.  But what if the server is running SSL - or what if the root page is
> protected by basic or some other such form of auth or access control?  I
> can work up some elaborate setup in which a request from the server's own
> IP address will pass all these checks.  Or I can push auth modules that
> return OK on non-main requests.

Why don't you just try it? It should work regardless. The auth stuff
should only happen if you actually call $subreq->run()

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org


Re: mod_perl: Configuration info at run-time

Posted by "Richard L. Goerwitz" <ri...@catlin.cis.brown.edu>.
Matt Sergeant wrote:

> OK then, try this:
> 
> for ($s = Apache->server; $s; $s = $s->next) {
>         my ($server, $port) = ($s->server_hostname, $s->port);
>         $r->print('server: ', $server, "\n");
>         $r->print('port: ', $port, "\n");
> 
>         my $subreq = $r->lookup_uri("http://$server:$port/");
>         $r->print('variable value: ', $subreq->dir_config('SomePerlVariable'), "\n");
> }

Ah.  But what if the server is running SSL - or what if the root page is
protected by basic or some other such form of auth or access control?  I
can work up some elaborate setup in which a request from the server's own
IP address will pass all these checks.  Or I can push auth modules that
return OK on non-main requests.

But this is pretty scary--and hard to maintain as servers change IP ad-
dresses or DNS names shift (yes, we can handle the address/name shifts
via <Perl> sections, but this seems overkill for what [I had thought]
would be a simple problem that should have been an easy solve).

(As you said, one would think that dir_config [called on a server object]
should have done the trick.)

-- 
Richard Goerwitz				Richard_Goerwitz@Brown.EDU

Re: mod_perl: Configuration info at run-time

Posted by Matt Sergeant <ma...@sergeant.org>.
On Tue, 13 Jun 2000, Richard L. Goerwitz wrote:

> To get a list of virtual servers -
> 
> > > > for (my $s = Apache->server; $s; $s = $s->next()) {
> > > >         print "Virtual host: ", $s->server_hostname, "\n";
> > > > }
> 
> > > Is there any reasonable way to use the list of servers (successive
> > > values of $s above) to determine what mod_perl PerlSetVar directives
> > > have been issued for each virtual host?
> > >
> > > E.g., is there some clever way to use Apache::ModuleConfig->get ()
> > > to do this?
> > 
> > $s->dir_config() should work.
> 
> You've actually hit upon my original reason for writing.  For whatever
> reason, the following code doesn't work for me.  The dir_config routine
> doesn't find what it's looking for (although it should - or at least so
> I thought):
> 
> sub handler () {
> 
>   my $r = shift;
>   my $vserver;
> 
>   $r->status (OK);
>   $r->content_type ('text/plain');
>   $r->send_http_header ();
> 
>   for ($vserver = Apache->server; $vserver; $vserver = $vserver->next) {
>     $r->print ('server: ', $vserver->server_hostname(), "\n");
>     $r->print ('port: ',   $vserver->port(), "\n");
>     $r->print ('variable value: ', $vserver->dir_config
> ('SomePerlVariable'), "\n");
>   }

OK then, try this:

for ($s = Apache->server; $s; $s = $s->next) {
	my ($server, $port) = ($s->server_hostname, $s->port);
	$r->print('server: ', $server, "\n");
	$r->print('port: ', $port, "\n");
	
	my $subreq = $r->lookup_uri("http://$server:$port/");
	$r->print('variable value: ',
$subreq->dir_config('SomePerlVariable'), "\n");
}

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org


Re: mod_perl: Configuration info at run-time

Posted by "Richard L. Goerwitz" <ri...@catlin.cis.brown.edu>.
To get a list of virtual servers -

> > > for (my $s = Apache->server; $s; $s = $s->next()) {
> > >         print "Virtual host: ", $s->server_hostname, "\n";
> > > }

> > Is there any reasonable way to use the list of servers (successive
> > values of $s above) to determine what mod_perl PerlSetVar directives
> > have been issued for each virtual host?
> >
> > E.g., is there some clever way to use Apache::ModuleConfig->get ()
> > to do this?
> 
> $s->dir_config() should work.

You've actually hit upon my original reason for writing.  For whatever
reason, the following code doesn't work for me.  The dir_config routine
doesn't find what it's looking for (although it should - or at least so
I thought):

sub handler () {

  my $r = shift;
  my $vserver;

  $r->status (OK);
  $r->content_type ('text/plain');
  $r->send_http_header ();

  for ($vserver = Apache->server; $vserver; $vserver = $vserver->next) {
    $r->print ('server: ', $vserver->server_hostname(), "\n");
    $r->print ('port: ',   $vserver->port(), "\n");
    $r->print ('variable value: ', $vserver->dir_config
('SomePerlVariable'), "\n");
  }

etc.

-- 
Richard Goerwitz				Richard_Goerwitz@Brown.EDU

Re: mod_perl: Configuration info at run-time

Posted by Matt Sergeant <ma...@sergeant.org>.
On Mon, 12 Jun 2000, Richard L. Goerwitz wrote:

> In response to my query about how to get a list of virtual
> servers, Matt Sergeant wrote:
> 
> > It's server->next():
> > 
> > for (my $s = Apache->server; $s; $s = $s->next()) {
> >         print "Virtual host: ", $s->server_hostname, "\n";
> > }
> 
> Here's a followup:
> 
> Is there any reasonable way to use the list of servers (successive
> values of $s above) to determine what mod_perl PerlSetVar directives
> have been issued for each virtual host?
> 
> E.g., is there some clever way to use Apache::ModuleConfig->get ()
> to do this?

$s->dir_config() should work.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org


Re: mod_perl: Configuration info at run-time

Posted by "Richard L. Goerwitz" <ri...@catlin.cis.brown.edu>.
In response to my query about how to get a list of virtual
servers, Matt Sergeant wrote:

> It's server->next():
> 
> for (my $s = Apache->server; $s; $s = $s->next()) {
>         print "Virtual host: ", $s->server_hostname, "\n";
> }

Here's a followup:

Is there any reasonable way to use the list of servers (successive
values of $s above) to determine what mod_perl PerlSetVar directives
have been issued for each virtual host?

E.g., is there some clever way to use Apache::ModuleConfig->get ()
to do this?

-- 
Richard Goerwitz				Richard_Goerwitz@Brown.EDU

Re: mod_perl: Configuration info at run-time

Posted by Matt Sergeant <ma...@sergeant.org>.
On Mon, 12 Jun 2000, Rob Tanner wrote:

> I don't have my eagle book in front of me (two work places, onbe book) -- 
> in chapter 9, I think it's a mod_perl specific method (might be a server 
> method though, can't remember) -- and I don't remember the name of the 
> function either -- but basically it returns a list of all configured 
> virtual hosts.
> 
> If no one else responds with a chapter and verse quote, skim through 
> chapter nine -- it's a full fledged reference manual -- and you should find 
> it.

It's server->next():

for (my $s = Apache->server; $s; $s = $s->next()) {
	print "Virtual host: ", $s->server_hostname, "\n";
}

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org


Re: mod_perl: Configuration info at run-time

Posted by Rob Tanner <rt...@onlinemac.com>.
I don't have my eagle book in front of me (two work places, onbe book) -- 
in chapter 9, I think it's a mod_perl specific method (might be a server 
method though, can't remember) -- and I don't remember the name of the 
function either -- but basically it returns a list of all configured 
virtual hosts.

If no one else responds with a chapter and verse quote, skim through 
chapter nine -- it's a full fledged reference manual -- and you should find 
it.

-- Rob

--On Monday, June 12, 2000 11:10 AM -0400 "Richard L. Goerwitz" 
<ri...@catlin.cis.brown.edu> wrote:

> It's not obvious to me how one might get a list of VirtualHosts that are
> configured for the current server instance (at run-time, e.g., from in-
> side a Perl module).
>
> Is there some canonical way to do this?
>
> --
> Richard Goerwitz				Richard_Goerwitz@Brown.EDU




       _ _ _ _           _    _ _ _ _ _
      /\_\_\_\_\        /\_\ /\_\_\_\_\_\
     /\/_/_/_/_/       /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
    /\/_/__\/_/ __    /\/_/    /\/_/          PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_/    /\/_/
  /\/_/ \/_/  /\/_/_/\/_/    /\/_/         (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/     \/_/              appears profound)

  Rob Tanner
  McMinnville, Oregon
  rtanner@onlinemac.com