Configless vhost

I have virtualhost with configuration less feature that works like a
charm!

server {
    server_name _;
    set $host_without_www $host;
    if ($host ~* www\.(.*)) {
      set $host_without_www $1;
    }
    root /var/www/$host_without_www/;
    access_log logs/$host_without_www.log;

unfortunately, access_log don´t parses variables, so a file named
$host_without_www.log
is created instead.

There´s any way to keep access logs separated by host, without need to
configure one by one by hand?

i believe variables are parsed at runtime, and someone just in the
last week or two brought up this too… i could be wrong but i believe
the answer is “no”

but it is something that is useful, i would believe, so it should be
added on a wishlist somewhere (i am still wanting to make that tool
and i am working on it slowly)

On Thu, Jun 26, 2008 at 04:26:54AM -0300, Marcos N. wrote:

unfortunately, access_log don?t parses variables, so a file named
$host_without_www.log
is created instead.

There?s any way to keep access logs separated by host, without need to
configure one by one by hand?

The attached patch allows variables in access_log.

It’s a proof-of-concept: for every log operation it opens/creates log,
writes, and then closes. It does not keep open frequently used logs.

It does not try to create log if a response status is 404 and there is
no root for the request.