我想读取 nginx.conf 中的 header ,其中包含“-”
x-foo-bar
使用 $http_name
$http_x-foo-bar变量的值变为“-foo-bar”
看起来它试图找到一个名为 x 的 header ,然后将 -foo-bar 附加到该值
有没有办法逃避这些“-”
我试过/但是 $http_x/-foo/-bar 给出/-foo/-bar 的值
最佳答案
根据 the documentation :
a variable name is the field name converted to lower case with dashes replaced by underscores
尝试:
$http_x_foo_bar
关于nginx header 变量转义 header 名称中的特殊字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39621473/