我试图在 Nginx 中的 http 指令中映射一个变量。
当单独存在时,变量单独被扩展,如果我向字符串添加任何其他内容,扩展将停止工作。
http {
map $host $foo {
#default "$host"; # - this works fine and returns 'localhost'
default "This is my host: $host"; # - THIS DOESN'T WORK
}
server {
location / {
echo $foo;
}
}
}
Run Code Online (Sandbox Code Playgroud)
您有什么建议可以使地图内的扩展工作吗?
map如指令文档中所述:
结果值可以是字符串或另一个变量 (0.9.0)。
更新:此功能已添加到 NGinx 1.11.2 版本中,根据此处的评论 #7:https ://trac.nginx.org/nginx/ticket/663#comment:7
| 归档时间: |
|
| 查看次数: |
9433 次 |
| 最近记录: |