-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
help request: remote_addr is error #11907
Comments
Could be attributed to Docker networking. Please see if |
docker-compose.yml services: apisix: networks: when I try use real-ip plugin , cause an exception. apisix logs (the ip is still wrong) when I use the model(Client -> Nginx -> APISIX -> Upstream) |
@SandNight I had a similar issue and adding the below apisix configuration in the httpSrv block of the nginx fixed the issue for me. Full block of code example: (line 476,477,478) |
thank you! None of them can get the correct ip |
Description
local ip_address:192.168.26.161
Expect the $remote_addr to be 192.168.26.161
1.Client -> APISIX -> Upstream
2.apisix run in docker(docker inspect apisix)
"NetworkSettings": {
"Bridge": "",
"SandboxID": "ae0f9cefd5c76958555b2c0fc6241337d40b9d4ef6aa1846b254190d8d131b4a",
"SandboxKey": "/var/run/docker/netns/ae0f9cefd5c7",
"Ports": {
"9080/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "9080"
}
],
"9091/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "9091"
}
],
"9092/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "9092"
}
],
"9180/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "9180"
}
],
"9443/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "9443"
}
]
},
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"apisix_apisix": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"apisix",
"apisix"
],
"MacAddress": "02:42:ac:13:00:02",
"DriverOpts": null,
"NetworkID": "51637f90967a97ccaf0620591d8703912801d789ab544152f05fe09de56789cc",
"EndpointID": "c680a20c9f5ad8c0715efa84e82be9c609b23966580af50b66a17ed0f42f7d05",
"Gateway": "172.19.0.1",
"IPAddress": "172.19.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"DNSNames": [
"apisix",
"9980822c47bf"
]
}
}
}
3.route config
{
"id": "548570123204559551",
"create_time": 1736502873,
"update_time": 1736502873,
"uri": "/gateway/*",
"name": "router-01",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
"CONNECT",
"TRACE",
"PURGE"
],
"plugins": {
"response-rewrite": {
"headers": {
"set": {
"X-Server-balancer-addr": "$balancer_ip:$balancer_port",
"remote_addr": "$remote_addr",
"remote_port": "$remote_port",
"X-proxy_add_x_forwarded_for":"$proxy_add_x_forwarded_for"
}
}
}
},
"upstream": {
"nodes": {
"192.168.26.161:8062": 1
},
"timeout": {
"connect": 6,
"send": 6,
"read": 6
},
"type": "roundrobin",
"scheme": "http",
"pass_host": "pass",
"keepalive_pool": {
"idle_timeout": 60,
"requests": 1000,
"size": 320
}
},
"enable_websocket": true,
"status": 1
}
4.when I request http://192.168.26.161:9080/gateway/hello
response header remote-addr is 172.19.0.1
and
docker logs -f apisix
172.19.0.1 - - [12/Jan/2025:05:13:45 +0000] 192.168.26.161:9080 "GET /gateway/hello HTTP/1.1" 200 549 0.079 "-" "PostmanRuntime-ApipostRuntime/1.1.0" 192.168.26.161:8062 200 0.078 "http://192.168.26.161:9080"
this clien ip is 172.19.0.1 but the real client ip is 192.168.26.161
Environment
apisix version
):uname -a
):openresty -V
ornginx -V
):curl http://127.0.0.1:9090/v1/server_info
):luarocks --version
):The text was updated successfully, but these errors were encountered: