nginx中如何设置全局变量
在nginx中设置全局变量可使用set指令。以下是设置全局变量的示例:
http {
# 设置全局变量
set $my_variable "hello world";
server {
location / {
# 使用全局变量
echo $my_variable;
}
}
}
在上述示例中,我们使用set指令将$my_variable设置为"hello world"。然后,在location块中,我们使用echo指令输出了这个全局变量的值。
TOP