有没有办法获得nginx的当前时间?

时间:2012-05-28 18:50:31

标签: nginx

我正在尝试将nginx服务器的时间注入HTTP标头。

我可以添加到HTTP标头,如下所示:

proxy_set_header HELLO-WORLD 'something';

但是现在,我希望能够将时间注入到HTTP头中,这看起来像这样:

proxy_set_header THE-TIME $time_var;

或类似的东西。

这可能吗?

2 个答案:

答案 0 :(得分:13)

您可以使用SSI模块中的变量:$ date_gmt和$ date_local

proxy_set_header THE-TIME $date_gmt;

http://nginx.org/en/docs/http/ngx_http_ssi_module.html#variables

答案 1 :(得分:3)

$time_iso8601既对机器又对人类友好。

相关问题