Re: Dynamic httpd.conf file using mod_perl...

2001-04-17 Thread Ask Bjoern Hansen

On Mon, 16 Apr 2001, Jim Winstead wrote:

[...]
 you would have to do a "run config template expander  HUP" instead
 of just doing a HUP of the apache parent process, but that doesn't
 seem like a big deal to me.

And it has the big advantage of also working with httpd's without
mod_perl.


 - ask

-- 
ask bjoern hansen, http://ask.netcetera.dk/   !try; do();
more than 70M impressions per day, http://valueclick.com




Re: Dynamic httpd.conf file using mod_perl...

2001-04-17 Thread Simon Rosenthal

At 04:16 AM 4/17/01, Ask Bjoern Hansen wrote:
On Mon, 16 Apr 2001, Jim Winstead wrote:

[...]
  you would have to do a "run config template expander  HUP" instead
  of just doing a HUP of the apache parent process, but that doesn't
  seem like a big deal to me.

And it has the big advantage of also working with httpd's without
mod_perl.

like proxy servers ...

  Going off on a slight tangent from the orginal topic - the template-based 
approach would also work well for subsystems that have separate 
configuration files - we put quite a bit of application configuration info 
into files other than httpd.conf, so that we can modify it without 
requiring a server restart.

-Simon



  - ask

--
ask bjoern hansen, http://ask.netcetera.dk/   !try; do();
more than 70M impressions per day, http://valueclick.com




Dynamic httpd.conf file using mod_perl...

2001-04-16 Thread Brian

I work for a small domain hosting company, and we currently host a few
hundred domains.  What I'm trying to do is have apache build the httpd.conf
file dynamically when it starts from a MySQL database.  Easy enough.  Got
most of it working, the only thing I'm running into is mod_rewrite problems.
Does anybody have any idea how to add the following:

RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^90.0.0.1$
RewriteRule .* http://www.whatever.com

to my current perl code (note - this isn't extracting info from the database
yet.  Just a simple text file for testing purposes):

Perl
  open(SC, " /www/conf/virtual-domains.conf") || die "$!";
  while(SC) {
chomp;
next if(/^s*#/);
my($sn,$sa,$ip,$htdir,$errlog,$translog) = split(/:/,$_,-1);
$VirtualHost{$sn} = {
  ServerName   = $sn,
  ServerAlias  = "www.".$sn",
  DocumentRoot = "/www/virtual/".$htdir,
  ErrorLog = "/www/virtual/".$htdir."logs/".$errlog,
  TransferLog  = "/www/virtual/".$htdir."logs/".$translog
};
  }
  close(SC);
__END__
/Perl

I'm thinking I can just add RewriteEngine = "on" to the VirtualHost hash.
But how do I handle the RewriteCond and the RewriteRule?  Can I make a hash
of hashes or something?  Maybe do something like:

RewriteCond = {'\%{REMOTE_ADDR}' = "!^90.0.0.1\$" },
RewriteRule = {'\.*' = "http://www.whatever.com" },

But that doesn't really work.  Just so you know, I've removed all of the
error checking for readability.  I didn't copy and paste this, so there
might be some syntax errors.  Anyway, if anybody can make a suggestion, or
point me at a web site I would appreciate it.  Thanks a ton in advance.

Brian Johnson
Systems Administrator/Programmer
Keweenet, LLC (www.keweenet.com)
Surgeon General announcement:
"Coffee is a direct substitute for sleep."




Re: Dynamic httpd.conf file using mod_perl...

2001-04-16 Thread Perrin Harkins

 What I'm trying to do is have apache build the httpd.conf
 file dynamically when it starts from a MySQL database.

It might be easier and more bulletproof to build the conf file off-line with
a simple perl script and a templating tool.  We did this with Template
Toolkit and it worked well.
- Perrin




RE: Dynamic httpd.conf file using mod_perl...

2001-04-16 Thread Brian

 It might be easier and more bulletproof to build the conf file
 off-line with
 a simple perl script and a templating tool.  We did this with Template
 Toolkit and it worked well.
 - Perrin

That would be fine and dandy, but it's not exactly what I'm going after.
Currently if I want to make a change to all of our clients I have to go
through and edit every config file (I have a .conf file for each domain and
then use an Include in the httpd.conf).  Using the mod_perl way I can change
it once in the httpd.conf file, restart apache, and the change will take
place for all the domains that are affected by the Perl /Perl code.
Know what I mean?

Brian Johnson
Systems Administrator/Programmer
Keweenet, LLC (www.keweenet.com)
Surgeon General announcement:
"Coffee is a direct substitute for sleep."




Re: Dynamic httpd.conf file using mod_perl...

2001-04-16 Thread Jim Winstead

On Mon, Apr 16, 2001 at 07:12:23PM -0400, Brian wrote:
  It might be easier and more bulletproof to build the conf file
  off-line with
  a simple perl script and a templating tool.  We did this with Template
  Toolkit and it worked well.
  - Perrin
 
 That would be fine and dandy, but it's not exactly what I'm going after.

it seems to me you're conflating your goal and your means of achieving
it.

 Currently if I want to make a change to all of our clients I have to go
 through and edit every config file (I have a .conf file for each domain and
 then use an Include in the httpd.conf).  Using the mod_perl way I can change
 it once in the httpd.conf file, restart apache, and the change will take
 place for all the domains that are affected by the Perl /Perl code.
 Know what I mean?

this is certainly possible by generating your configuration files
using a perl script, outside of using mod_perl.

jim



RE: Dynamic httpd.conf file using mod_perl...

2001-04-16 Thread Brian


 it seems to me you're conflating your goal and your means of achieving
 it.

I don't think I'm conflating the goal and the means.  At least I don't see
how I am

 this is certainly possible by generating your configuration files
 using a perl script, outside of using mod_perl.

Aaah, but you see that would create a bunch of configuration files or make
one huge configuration file.  My method would eliminate all but one
configuration file (httpd.conf) and use our billing database to create the
configuration files.  That way when a client is deactivated in the DB it's
automatically deactivated in apache the next time it's HUP'ed.  Yeah, I
could write a separate perl script to go in, find the line that says
"Include /www/conf/viraul/domain.conf" and then pound it out and restart the
server.  I can also write a perl script to create all the config files for
me.  But why not do both in the config file if possible?

It's all written, only problem is the mod_rewrite directives.  Any ideas on
how to do them in a Perl directive?  Thanks in advance.

Brian Johnson
Systems Administrator/Programmer
Keweenet, LLC (www.keweenet.com)
Surgeon General announcement:
"Coffee is a direct substitute for sleep."




Re: Dynamic httpd.conf file using mod_perl...

2001-04-16 Thread Jim Winstead

On Mon, Apr 16, 2001 at 07:37:32PM -0400, Brian wrote:
 
  it seems to me you're conflating your goal and your means of achieving
  it.
 
 I don't think I'm conflating the goal and the means.  At least I don't see
 how I am

well, perhaps that wasn't the best way to put it.

  this is certainly possible by generating your configuration files
  using a perl script, outside of using mod_perl.
 
 Aaah, but you see that would create a bunch of configuration files or make
 one huge configuration file.  My method would eliminate all but one
 configuration file (httpd.conf) and use our billing database to create the
 configuration files.  That way when a client is deactivated in the DB it's
 automatically deactivated in apache the next time it's HUP'ed.  Yeah, I
 could write a separate perl script to go in, find the line that says
 "Include /www/conf/viraul/domain.conf" and then pound it out and restart the
 server.  I can also write a perl script to create all the config files for
 me.  But why not do both in the config file if possible?

and the suggestion perrin made would have basically the same result.
your configuration file would be a template, basically, that was
expanded into the real configuration file that is then read by the
apache process. it is very close to what you are doing, without
introducing the vagaries of getting mod_perl and mod_rewrite
to cooperate.

you would have to do a "run config template expander  HUP" instead
of just doing a HUP of the apache parent process, but that doesn't
seem like a big deal to me.

 It's all written, only problem is the mod_rewrite directives.  Any ideas on
 how to do them in a Perl directive?  Thanks in advance.

nope.

jim



Re: Dynamic httpd.conf file using mod_perl...

2001-04-16 Thread ___cliff rayman___

checkout the following link:
http://www.geocrawler.com/archives/3/182/2000/3/0/3377287/

the search engine at:
http://www.geocrawler.com/lists/3/Web/182/0/

is your friend.

--
___cliff [EMAIL PROTECTED]http://www.genwax.com/

Brian wrote:

 It's all written, only problem is the mod_rewrite directives.  Any ideas on
 how to do them in a Perl directive?  Thanks in advance.







Re: Dynamic httpd.conf file using mod_perl...

2001-04-16 Thread Perrin Harkins

  It might be easier and more bulletproof to build the conf file
  off-line with
  a simple perl script and a templating tool.  We did this with Template
  Toolkit and it worked well.
  - Perrin

 That would be fine and dandy, but it's not exactly what I'm going after.
 Currently if I want to make a change to all of our clients I have to go
 through and edit every config file (I have a .conf file for each domain
and
 then use an Include in the httpd.conf).  Using the mod_perl way I can
change
 it once in the httpd.conf file, restart apache, and the change will take
 place for all the domains that are affected by the Perl /Perl code.
 Know what I mean?

Sure, and it looks like you got your question answered.  The two approaches
are pretty similar in terms of the results, but the off-line approach does
require either using a custom startup script or doing two steps (build conf
and then restart server).  On the other hand, the off-line approach will
allow you to start your server even when the database is down.  You might
want to build your dynamic conf file approach with a cache for the
last-accessed database info, so that it has something to fall back to if the
db goes down.
- Perrin




RE: Dynamic httpd.conf file using mod_perl...

2001-04-16 Thread Brian

Thanks all for the suggestions and idea provoking chatter.  I appreciate.  I
also much apologize as I didn't fully comprehend your first suggestion
Perrin.  Simple mind lapse caused by a lack of sleep and not enough
caffeine.  :o)

But, you are right about the DB being down.  A cache is a must in such a
case.  Thank you for pointing that out.  :o)

Brian Johnson
Systems Administrator/Programmer
Source1hosting.tv (www.source1hosting.tv)
Surgeon General announcement:
"Coffee is a direct substitute for sleep."

 Sure, and it looks like you got your question answered.  The two
 approaches
 are pretty similar in terms of the results, but the off-line approach does
 require either using a custom startup script or doing two steps
 (build conf
 and then restart server).  On the other hand, the off-line approach will
 allow you to start your server even when the database is down.  You might
 want to build your dynamic conf file approach with a cache for the
 last-accessed database info, so that it has something to fall
 back to if the
 db goes down.
 - Perrin