Nginx代理后如何针对请求的Client IP进行限流
- Dominant language
- Java
- Stars
- 23.1k
- Forks
- 8.1k
- PR merge metrics
- No merged PRs in 30d
Description
## 因为使用了Nginx,针对请求的Client IP进行限流时有问题

`所有请求获取到的ip地址都为同一个地址172.*.*.*,(应用部署在docker容器内)。`
看了下com.alibaba.csp.sentinel.adapter.gateway.sc.ServerWebExchangeItemParser#getRemoteAddress的方法,获取ip时使用的代码是
```
public String getRemoteAddress(ServerWebExchange exchange) {
InetSocketAddress remoteAddress = exchange.getRequest().getRemoteAddress();
return remoteAddress == null ? null : remoteAddress.getAddress().getHostAddress();
}
```
是否可以自定义获取请求ip地址?或者可以让sentinel得到代理后真实请求ip的方法
Contributor guide
Research direction
Start with com.alibaba.csp.sentinel.adapter.gateway.sc.ServerWebExchangeItemParser#getRemoteAddress and reproduce the reported client-IP behavior through Nginx into the Docker-deployed application. Check how the gateway adapter obtains the request address and determine whether proxy-aware or configurable address handling is supported; done means requests are rate-limited by the real client IP rather than the shared 172.*.*.* address.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, nginx
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100