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

标签 nginx http-headers

我想读取 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/

相关文章:

node.js - ExpressJS 服务器每晚离线 - 502 Bad Gateway

docker nginx代理nginx connect()失败(111 : Connection refused) while connecting to upstream

ssl - 续订 letsencrypt SSL 证书后,服务器仅返回响应代码 400

ubuntu - 如何从 Docker 提供 Harp/nginx 页面?

php - 如何处理来自代理的额外 HTTP header ?

java - IIS6 中缺少 header (ColdFusion,可能还有其他语言)

Angular 7 未按要求发送正确的 header

apache - 找不到 nginx 代理页面

java - Spring Global CORS 配置不起作用,但 Controller 级别配置起作用

Node.js HEAD http 请求