kayx23 commented on issue #9433: URL: https://github.com/apache/apisix/issues/9433#issuecomment-1549415661
## TEST: Both Plugins Enabled in the Same Global Rule First, create a route pointing to httpbin.org `/anything` ``` curl "http://127.0.0.1:9180/apisix/admin/routes" -H "X-API-KEY: xxxx" -X PUT -d ' { "id": "getting-started-anything", "uri": "/anything", "upstream" : { "type": "roundrobin", "nodes": { "httpbin.org": 1 } } }' ``` Create a global rule with both plugins enabled: ``` $ curl http://127.0.0.1:9180/apisix/admin/global_rules/1 -H "X-API-KEY: xxxx" -X PUT -d '{ "id":"1", "plugins":{ "ip-restriction":{ "whitelist":[ "10.140.0.2", "172.17.0.1", "172.18.0.1" ], "message": "Your IP address is not allowed" }, "real-ip":{ "source": "http_x_forwarded_for" } } }' ``` ``` {"key":"/apisix/global_rules/1","value":{"update_time":1684232635,"plugins":{"real-ip":{"source":"http_x_forwarded_for","recursive":false},"ip-restriction":{"whitelist":["10.140.0.2","172.17.0.1","172.18.0.1"],"message":"Your IP address is not allowed"}},"create_time":1684229345,"id":"1"}} ``` * Note: IP addresses in whitelist are updated to my host's IPs. Curl to the endpoint to see if the request goes through: ``` $ curl "http://127.0.0.1:9080/anything" -H "x_forwarded_for: 100.123.1.16" { "args": {}, "data": "", "files": {}, "form": {}, "headers": { "Accept": "*/*", "Host": "127.0.0.1", "User-Agent": "curl/7.74.0", "X-Amzn-Trace-Id": "Root=1-646359c9-4f710db67cf47e734cf402a5", "X-Forwarded-Host": "127.0.0.1" }, "json": null, "method": "GET", "origin": "172.18.0.1, 34.81.252.xxx, 100.123.1.16", "url": "http://127.0.0.1/anything" } ``` The request went through; the returned result showed `100.123.1.16` as one of the origins. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
