Applenice opened a new issue #814:
URL: https://github.com/apache/apisix-dashboard/issues/814


   Please answer these questions before submitting your issue.
   
   - Why do you submit this issue?
   - [ ] Question or discussion
   - [X] Bug
   - [ ] Requirements
   - [ ] Feature or performance improvement
   - [ ] Other
   
   ___
   ### Question
   - What do you want to know?
   `proxy-rewrite` plugin header configuration is not working,capturing packets 
by tcpdump reveals that the http request does not carry header information.
   
   ___
   ### Bug
   - Which version of Apache APISIX Dashboard, OS, and Browser?
   ```
   $ 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)
   ```
   - What happened?
   
   Client   192.168.199.213   Curl 7.55.1
   apisix and apisix-dashboard  192.168.199.118 
   
   ##### Use API Method
   ```
   $ 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.
   
   ##### Use Dashboard
   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?
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to