Replies: 9 comments 24 replies
-
The default is to use apisix/conf/config-default.yaml Line 200 in c201d72 verify: route: curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uri": "/hello",
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:1980": 1
}
},
"plugins": {
"ip-restriction": {
"whitelist": [
"127.0.0.1"
]
}
}
}' send request from curl http://127.0.0.1:9080/hello '
1234567890# send request from curl http://127.0.0.1:9080/hello -H "X-Real-IP: 192.168.0.1"
{"message":"Your IP address is not allowed"} |
Beta Was this translation helpful? Give feedback.
-
另一个示例
2、请求
3、打印的日志
|
Beta Was this translation helpful? Give feedback.
-
@tzssangglass 还请百忙之中抽点时间解疑,谢谢。 |
Beta Was this translation helpful? Give feedback.
-
我知道如何获取X-Real-IP。这里综上的例子,看起来IP白名单whitelist策略match的是$remote_addr,而不是取X-Real-IP 的值 @tzssangglass |
Beta Was this translation helpful? Give feedback.
-
You should be concerned about getting your front-end Nginx or LB to carry real client IP to APISIX |
Beta Was this translation helpful? Give feedback.
-
前边的日志格式和日志内容表明 real client ip 是正确的,源代码init.lua里也没看到有关real ip:
|
Beta Was this translation helpful? Give feedback.
-
综合上述的信息,看起来IP白名单插件使用的是$remote_addr match whitelist,然而给的示例似乎是将x-real-ip赋值给了$remote_addr,如果属实,这个逻辑是不对的,白名单IP应该使用x-real-ip match whitelist,当x-real-ip值为空时,默认赋值$remote_addr,$remote_addr获取的IP应该始终是request client ip,不应该被更改。 |
Beta Was this translation helpful? Give feedback.
-
刚从官方git仓库拉了个最新版,dashboard 2.13, apisix 2.99 ,什么都没更改,请求没经过任何代理,结果仍然是不行,whitelist中匹配到remote_addr才可行,不清楚您给的示例是什么配置 |
Beta Was this translation helpful? Give feedback.
-
I think you should focus your question on understanding how APISIX gets the real client IP. Refer to the link I gave above. Again, it makes sense for the ip-restriction plugin to use the $remote_addr variable to get the real client IP. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
问题描述:
apisix位于LB或者nginx后,使用IP白名单限制访问路由,结果未生效,大概看了下插件的源码,似乎是匹配的remote_addr,不知道是否正确?因为我不是研发,lua以前学过一点语法很久没看了。如果取自remote_addr,似乎不是太合适,是基于什么考虑不取x-real-ip,尽管x-real-ip可能不存在,但是我们可以默认赋值remote_addr。
Beta Was this translation helpful? Give feedback.
All reactions