Skip to content

help request: remote_addr is error #11907

@SandNight

Description

@SandNight

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 (run apisix version):
  • apache/apisix:3.11.0-debian
  • Operating system (run uname -a):
  • Darwin JadeMac.local 21.6.0 Darwin Kernel Version 21.6.0: Mon Jun 24 00:56:10 PDT 2024; root:xnu-8020.240.18.709.2~1/RELEASE_X86_64 x86_64
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • bitnami/etcd:3.4.15
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionlabel for questions asked by users

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions