Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proxy-rewrite header invalid configuration #814

Closed
1 of 5 tasks
Applenice opened this issue Nov 16, 2020 · 4 comments
Closed
1 of 5 tasks

proxy-rewrite header invalid configuration #814

Applenice opened this issue Nov 16, 2020 · 4 comments
Assignees
Labels
bug Something isn't working duplicate This issue or pull request already exists plugin
Milestone

Comments

@Applenice
Copy link
Contributor

Please answer these questions before submitting your issue.

  • Why do you submit this issue?
  • Question or discussion
  • 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?

@liuxiran
Copy link
Contributor

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/plugin will be upgraded to 1.0.14+ .

@liuxiran liuxiran added bug Something isn't working duplicate This issue or pull request already exists labels Nov 17, 2020
@Applenice
Copy link
Contributor Author

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/plugin will be upgraded to 1.0.14+ .

So that's it, hope to upgrade soon, thanks!😃

@juzhiyuan
Copy link
Member

We are working on a feature for the plugin module, that you could pass JSON directly to API instead of using Form.

@juzhiyuan
Copy link
Member

juzhiyuan commented Nov 17, 2020

We will keep both Form and code-mirror.

All plugins will support this, and it will resolve all most UI issues finally!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists plugin
Projects
None yet
Development

No branches or pull requests

3 participants