orlabs / orange

OpenResty/Nginx Gateway for API Monitoring and Management.
http://orange.sumory.com
MIT License
2.31k stars 575 forks source link

分流插件中使用,Header中获取key时,key包含下划线_导致value获取失败 #409

Open sydowma opened 4 years ago

sydowma commented 4 years ago

针对Orange使用的提问,对于简单几句话描述不清的问题,请使用以下格式,不符合格式或描述含糊不清的issue将不予回复。根据问题模板填写好后,提问之前请去除模板的无用内容。

使用的Orange版本

v0.8.1

需求或场景

使用分流插件,获取使用 Header 中的key来判断是否要分流

使用的插件

分流插件-divide

具体的配置
image

{   "name": "hello1",   "judge": {     "type": 0,     "conditions": [       {         "type": "Header",         "name": "work_code",         "operator": "=",         "value": "11111"       }     ]   },   "extractor": {     "type": 1,     "extractions": []   },   "upstream_host": "",   "upstream_url": "http://default_upstream",   "log": true,   "enable": true }
2020/03/01 19:32:09 [info] 12533#12533: *10652 [lua] handler.lua:95: access(): ==[Divide][PASS THROUGH SELECTOR:e4ed6bee-4666-47d0-a780-1a6c1a648ad8], client: 124.xx.xx.xx, server: , request: "GET / HTTP/1.1", host: "www.baidu.com"
2020/03/01 19:32:09 [info] 12533#12533: *10652 [lua] handler.lua:107: access(): [Divide][PASS-SELECTOR:e4ed6bee-4666-47d0-a780-1a6c1a648ad8] /, client: xx.xx.xx.xx, server: , request: "GET / HTTP/1.1", host: "www.baidu.com"
2020/03/01 19:32:09 [error] 12533#12533: *10652 [lua] condition.lua:10: judge(): assert_condition error: nil = 111111, client: xx.xx.xx.xx, server: , request: "GET / HTTP/1.1", host: "www.baidu.com"
2020/03/01 19:32:09 [info] 12533#12533: *10652 [lua] handler.lua:60: filter_rules(): [Divide-NotMatch-Rule] hello1 host:www.baidu.com uri:/, client: xx.xx.xx.xx, server: , request: "GET / HTTP/1.1", host: "www.baidu.com"
2020/03/01 19:32:09 [info] 12533#12533: *10652 [lua] handler.lua:37: filter_rules(): [Divide-Match-Rule] default host:www.baidu.com uri:/, client: xx.xx.xx.xx, server: , request: "GET / HTTP/1.1", host: "www.baidu.com"
2020/03/01 19:32:09 [info] 12533#12533: *10652 [lua] handler.lua:51: filter_rules(): [Divide-Match-Rule:upstream] default extractor_type:1 upstream_host:www.baidu.com upstream_url:http://baidu, client: xx.xx.xx.xx, server: , request: "GET / HTTP/1.1", host: "www.baidu.com"

将key中间的下划线删掉后,问题恢复。

sydowma commented 4 years ago

@wujunze @shuaijinchao 大佬帮忙看一下

shz8 commented 4 years ago

在usr/local/orange/conf/nginx.conf 的 http{} 里加一行 underscores_in_headers on;