nginx 标头变量转义标头名称中的特殊字符

Pat*_*way 3 nginx http-headers

我想读取 nginx.conf 中的标题,其中包含“-”

x-foo-bar

使用 $http_name

$http_x-foo-bar 变量的值变成“-foo-bar”

看起来它试图找到一个名为 x 的标头,然后将 -foo-bar 附加到该值

有什么办法可以逃避这些“-”

我试过 / 但 $http_x/-foo/-bar 给出了 /-foo/-bar 的值

Ric*_*ith 5

根据文档

变量名称是转换为小写的字段名称,短划线替换为下划线

尝试:

$http_x_foo_bar
Run Code Online (Sandbox Code Playgroud)