有没有办法在nginx中获取当前时间? [英] Is there a way to get the current time in nginx?

查看:2204
本文介绍了有没有办法在nginx中获取当前时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to inject the time of an nginx server into an HTTP header.

我能够添加到HTTP标头,如下所示:

I am able to add to an HTTP header, like so:

proxy_set_header HELLO-WORLD 'something';

但是现在,我希望能够将时间注入到HTTP标头中,如下所示:

But now, I want to be able to inject the time into an HTTP header, something that looks like this:

proxy_set_header THE-TIME $time_var;

或者类似的东西.

有可能吗?

推荐答案

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

You can use variables from SSI modulе: $date_gmt and $date_local

proxy_set_header THE-TIME $date_gmt;

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

这篇关于有没有办法在nginx中获取当前时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆