can a map + regex be used to generate variables for YYYY-MM-DD-HH?

Francis Daly francis at
Fri Oct 24 18:12:12 UTC 2014

On Fri, Oct 24, 2014 at 01:44:19PM -0400, newnovice wrote:

Hi there,

> 1. variable in logname is what i want: access_log.YYYY-MM-DD-HH

That can work.

> 2. (currently i use this method) 'if' - inside server - outside location -
> works.

That's good. Note that "if" inside "location" should not be used unless
you "return" or "rewrite...last", unless you know what you are doing.

But where you have it, inside server{}, is fine.

> Only when i get non ssl traffic to 443 port it writes out
> access_log.---- instead of the usual: 'access_log.2014-10-24-17' 
> 2.1 is this a bug ? 

It looks to me like it might be.

* I would naively have expected error_log output there, not access_log.
* The number of "-" in the file name looks wrong.

> 3. also tried map inside server block - outside location & its not allowed
> there. -- correct, "map" only goes at http level.

You can refer to the variable that it creates, at server level.

Francis Daly        francis at

More information about the nginx mailing list