1. 问题
由于在http请求头的头部中设置了一些自定义字段,刚好这些字段中含有下划线,比如bundle_name这种,后端在进去获取头部信息时,发现取不到对应的值
原因是 nginx对header name的字符做了限制,默认 underscores_in_headers 为off,表示如果header name中包含下划线,则忽略掉。而我的自定义header中恰巧有下划线变量。
2. 原因及解决办法
方法一:
header中自定义变量名时不要用下划线
方法二:
在nginx.conf中加上underscores_in_headers on
配置
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
underscores_in_headers on;
keepalive_timeout 65;
}