nginx_tcp_proxy_module icon indicating copy to clipboard operation
nginx_tcp_proxy_module copied to clipboard

nginx在做tcp反向代理后,有什么办法把所选择的后台服务器地址,告知外面的系统?

Open dopilas opened this issue 10 years ago • 2 comments

我们有个项目,不仅需要做tcp反向代理,还需要知道对某次tcp连接,反向代理选择了那台服务器。 不知道有没有这个接口,如果没有,有什么建议? 谢谢

dopilas avatar Jun 24 '15 10:06 dopilas

如果现在没有,那么yaoweibin兄弟能不能提示下,在源代码的哪些地方修改,可以获取这个信息? 提前感谢!

dopilas avatar Jun 24 '15 10:06 dopilas

@dopilas 以rr算法为例子,参考如下callgraph:

ngx_tcp_upstream_connect
  -> ngx_event_connect_peer
     -> ngx_tcp_upstream_get_round_robin_peer (pc->get)

ngx_tcp_upstream_get_round_robin_peer会选取出upstream peer

chobits avatar Aug 13 '15 12:08 chobits