Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to have my Nginx load balancer send a timestamp in a header onto the upstream servers.

I tried something like this:

proxy_set_header X-Start-Time $msec;

Of course, $msec is a log variable and Nginx gives an error:

Restarting nginx: [emerg]: unknown "msec" variable
share|improve this question
up vote 0 down vote accepted

$msec is indeed a variable that lives only during log writing.

The easiest solution would be to build Nginx with Perl module and define a variable backed by Perl subroutine:

# at 'http' context
perl_set $unix_timestamp 'sub {

# where you want it:
proxy_set_header X-Start-Time $unix_timestamp;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.