APISIX should support to get original destination address and port
tokers opened this issue · 8 comments
In the case of APISIX as the inbound proxy for an application, the destination of traffic sent to APISIX was the application originally (redirected by iptables rules), after APISIX processed the traffic, ran a several plugins, it should be re-sent to the application, so APISIX has to know the original destination address.
Currently, we cannot get the original address and port from the connection fd, we may patch nginx to provide these two variables, like $connection_original_addr
and $connectino_original_port
, just call getsockopt
with SO_ORIGINAL_DST
option.
After APISIX has this capability, we can inject a new server by apisix-mesh-agent, which at lease has the following configurations.
server {
listen 127.0.0.1:9081 reuseport;
location / {
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_pass http://$connection_original_addr:$connection_original_port;
}
}
@membphis @spacewander Please take a look when you have time.
We need to patch Nginx to support this feature.
There are two ways:
- fetch value directly through nginx variables.
- add API to fetch the socket fd, and use Lua FFI to fetch the
connection_original_addr
.
The second method is more common, what do you think? @spacewander @tokers
If we use a second way, so we have to develop another upstream node setting method to combine the value from the lua ffi call.
We may create another upstream discovery type named passing through. In such a case, APISIX will get endpoints with the original destination.
Supported.