Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: ModPerl

on-the-fly ServerAlias additions

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


john-modperl at o-rourke

Sep 15, 2008, 3:05 AM

Post #1 of 5 (534 views)
Permalink
on-the-fly ServerAlias additions

Hi folks,

I'm trying and failing to find this specific info in the docs - I'd like
to add ServerAlias directives while Apache is running.

Is this possible through Apache2::ServerUtil::add_config ?

If so I'm guessing the next problem would be propagating that to all the
child processes, although that could be achieved by telling them to exit
after the next request.

Any help appreciated and apologies if I haven't scoured the list
archives closely enough.

cheers
John


torsten.foertsch at gmx

Sep 15, 2008, 4:15 AM

Post #2 of 5 (509 views)
Permalink
Re: on-the-fly ServerAlias additions [In reply to]

On Mon 15 Sep 2008, John ORourke wrote:
> I'm trying and failing to find this specific info in the docs - I'd
> like to add ServerAlias directives while Apache is running.
>
> Is this possible through Apache2::ServerUtil::add_config ?

That's impossible, I am afraid; even PerlPostReadRequest is run after
the vhost is determined. At runtime you can add only directives that
are valid in directory/files/htaccess context via $r->add_config.

The only way is to patch the config file and send the supervisor httpd a
SIGUSR1 (graceful restart).

The other way would be not to use named vhosts at all and write a
PerlTransHandler that looks at $r->headers_in->{Host} and decides what
to do. I use that approach quite often. The only problem seen so far is
the error_log. There can be only one. The access_log can be splitted
into several files using environment variables. Using prefork mod_perl
lets you set even DocumentRoot per request. Depends upon the complexity
of your config whether that is feasible for you.

A 3rd way could be a connection level input filter that patches the host
header. But you don't want to do that!

Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch[at]gmx.net


deepfryed at gmail

Sep 15, 2008, 4:50 AM

Post #3 of 5 (508 views)
Permalink
Re: on-the-fly ServerAlias additions [In reply to]

> That's impossible, I am afraid; even PerlPostReadRequest is run after
> the vhost is determined. At runtime you can add only directives that
> are valid in directory/files/htaccess context via $r->add_config.
>
> The only way is to patch the config file and send the supervisor httpd a
> SIGUSR1 (graceful restart).


Yeah what Torsten said :-)

But I'm lazy and in the past i've used the Include config directive to
load all vhost or server alias directives in a given subdirectory.
Once I add a new config directive, a graceful restart will get apache
to reload the new config directives. So no patching configs really,
just create or delete directive files from the appropriate
subdirectories.


perrin at elem

Sep 15, 2008, 8:52 AM

Post #4 of 5 (503 views)
Permalink
Re: on-the-fly ServerAlias additions [In reply to]

On Mon, Sep 15, 2008 at 7:50 AM, <deepfryed[at]gmail.com> wrote:
> But I'm lazy and in the past i've used the Include config directive to
> load all vhost or server alias directives in a given subdirectory.
> Once I add a new config directive, a graceful restart will get apache
> to reload the new config directives. So no patching configs really,
> just create or delete directive files from the appropriate
> subdirectories.

See also mod_rewrite and RewriteMap. You can modify the rewrite rules
on the fly without restarting your server.

- Perrin


john-modperl at o-rourke

Sep 15, 2008, 9:34 AM

Post #5 of 5 (504 views)
Permalink
Re: on-the-fly ServerAlias additions [In reply to]

Perrin Harkins wrote:
> On Mon, Sep 15, 2008 at 7:50 AM, <deepfryed[at]gmail.com> wrote:
>
>> But I'm lazy and in the past i've used the Include config directive to
>> load all vhost or server alias directives in a given subdirectory.
>>
> See also mod_rewrite and RewriteMap. You can modify the rewrite rules
> on the fly without restarting your server.
>

Thanks for all the advice folks - I'm going to go for "ServerAlias *" in
my last VirtualHost, so we can add aliases on the fly with no config
changes, because luckily I can restrict new aliases to just one vhost on
a given server. I don't want to use the first (default) vhost at the
moment because of the way the system is set up. My handler can happily
reject or otherwise handle any unrecognised hostnames.

cheers
John

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.