Please answer these questions before submitting your issue.
proxy-rewrite plugin header configuration is not working锛宑apturing packets by tcpdump reveals that the http request does not carry header information.$ pwd
/usr/local/src/apisix
$ git branch -v
* master c1ac7d6 docs: add a English link of node-status.md (#2753)
$ pwd
/usr/local/src/apisix-dashboard
$ git branch -v
* v2.0 59515b5 feat: skip puppeteer chromium download when build (#808)
Client 192.168.199.213 Curl 7.55.1
apisix and apisix-dashboard 192.168.199.118
$ curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
> {
> "methods": ["GET"],
> "uri": "/geo/*",
> "plugins": {
> "proxy-rewrite": {
> "regex_uri": ["^/geo/(.*)$","/json/$1"],
> "scheme": "http",
> "host": "ip-api.com",
> "headers": {
> "X-Api-Version": "v1",
> "X-Api-Engine": "apisix",
> "Accept": "application/json"
> }
> }
> },
> "upstream": {
> "type": "roundrobin",
> "nodes": {
> "ip-api.com:80": 1
> }
> }
> }'
{"header":{"revision":"43","cluster_id":"14841639068965178418","raft_term":"6","member_id":"10276657743932975437"},"action":"set","node":{"key":"\/apisix\/routes\/1","value":{"priority":0,"uri":"\/geo\/*","upstream":{"hash_on":"vars","nodes":{"ip-api.com:80":1},"type":"roundrobin","pass_host":"pass"},"id":"1","update_time":1605537606,"plugins":{"proxy-rewrite":{"scheme":"http","host":"ip-api.com","headers":{"X-Api-Version":"v1","Accept":"application\/json","X-Api-Engine":"apisix"},"regex_uri":["^\/geo\/(.*)$","\/json\/$1"]}},"create_time":1605537606,"methods":["GET"]}}}
Request with curl on the client and run tcpdump on the machine where APISIX is located. Follow TCP Stream result:
GET /json/8.8.8.8 HTTP/1.1
Host: ip-api.com
X-Real-IP: 192.168.199.213
X-Forwarded-For: 192.168.199.213
X-Forwarded-Proto: http
X-Forwarded-Host: 192.168.199.118
X-Forwarded-Port: 9080
User-Agent: curl/7.55.1
Accept: application/json
X-Api-Version: v1
X-Api-Engine: apisix
HTTP/1.1 200 OK
Custom Header information is carried in the API method.
After I configured it, I observed the network request and here is the configuration returned:
{
"id": "328844533926199973",
"create_time": 1605536216,
"update_time": 1605539246,
"uris": [
"/ip/*"
],
"name": "T-3",
"methods": [
"GET"
],
"hosts": [
"192.168.199.118"
],
"vars": [],
"plugins": {
"proxy-rewrite": {
"headers": {
"Accept": {
"key": "Accept",
"value": "application/json"
},
"X-Api-Engine": {
"value": "apisix"
},
"X-Api-Version": {
"value": "v1"
}
},
"host": "ip-api.com",
"regex_uri": [
"^/ip/(.*)$",
"/json/$1"
],
"scheme": "http"
}
},
"upstream": {
"nodes": [
{
"host": "ip-api.com",
"port": 80,
"weight": 1
}
],
"timeout": {
"connect": 6000,
"read": 6000,
"send": 6000
},
"type": "roundrobin"
}
},
Also run tcpdump on the machine where APISIX is located.Follow TCP Stream result:
GET /json/8.8.8.8 HTTP/1.1
Host: ip-api.com
X-Real-IP: 192.168.199.213
X-Forwarded-For: 192.168.199.213
X-Forwarded-Proto: http
X-Forwarded-Host: 192.168.199.118
X-Forwarded-Port: 9080
User-Agent: curl/7.55.1
HTTP/1.1 200 OK
After comparison, it can be seen that Header information is not carried at all when configured via Dashboard.
Another question: why is the Accept field in header formatted differently than the X-Api-Engine and X-Api-Version fields?
Thanks for your feedback, the same reason as https://github.com/apache/apisix-dashboard/issues/793, there are some transform errors in fe plugin component, and after the errors fixed, @api7-dashboard/plugin will be upgraded to 1.0.14+ .
Thanks for your feedback, the same reason as #793, there are some transform errors in fe plugin component, and after the errors fixed,
@api7-dashboard/pluginwill be upgraded to1.0.14+ .
So that's it, hope to upgrade soon, thanks!馃槂
We are working on a feature for the plugin module, that you could pass JSON directly to API instead of using Form.
We will keep both Form and code-mirror.
All plugins will support this, and it will resolve all most UI issues finally!
Most helpful comment
We will keep both Form and code-mirror.
All plugins will support this, and it will resolve all most UI issues finally!