on-the-fly ServerAlias additions - modperl

This is a discussion on on-the-fly ServerAlias additions - modperl ; 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 ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: on-the-fly ServerAlias additions

  1. 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


  2. Re: on-the-fly ServerAlias additions

    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@gmx.net


  3. Re: on-the-fly ServerAlias additions

    > 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.


  4. Re: on-the-fly ServerAlias additions

    On Mon, Sep 15, 2008 at 7:50 AM, 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


  5. Re: on-the-fly ServerAlias additions

    Perrin Harkins wrote:
    > On Mon, Sep 15, 2008 at 7:50 AM, 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


+ Reply to Thread