我正在尝试在我的单独 Web 服务器上设置响应 header ,以输出运行 nginx 的机器的物理名称,以便我可以知道哪些服务器正在为我们的 Web 客户端提供响应。
是否已经存在一个变量来执行此操作?还是我只需要在每个服务器上对其进行硬编码:(
最佳答案
您正在关注 $hostname公共(public)变量。 variable index 中列出了常用变量。 .
nginx access log documentation仅显示特定于访问日志的变量:
The log format can contain common variables, and variables that exist only at the time of a log write.
关于物理服务器名称的 Nginx 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24915159/