如何在Nginx UDP LoadBalancer中添加Proxy_pass_header参数到Preserver目标IP
我已经在C中创建了一个客户端服务器应用程序。我的客户端位于不同的VM上,服务器位于不同的VM上。 在服务器端,我正在使用nginx加载平衡器,nginx load平衡器接受客户端的请求,然后将请求发送到相应的容器,但是当LoadBalancer将请求发送到容器时,它会修改其标题(即源IP和目标IP),当我获取目标时,来自数据包的IP将容器IP作为目标IP提供,我想要的是我们从数据包中获取实际目标IP的方式。
Client IP : 192.x.x.x
Server IP : 192.x.x.y
Loadbalancer IP : 172.17.x.x
Container IP : 172.17.x.y
Flow :
client -> loadbalacer -> container
Client Sends Header (src : 192.x.x.x, dst 192.x.x.y)
Loadbalancer Recvd Header (src : 192.x.x.x, dst 192.x.x.y)
Loadbalancer Sends Header (src 172.17.x.x, dst 172.17.x.y)
Container Recvd Header (src 172.17.x.x, dst 172.17.x.y)
我实际上在寻找的东西:
Loadbalancer Sends Header (src 192.x.x.x, dst 192.x.x.y)
Container Recvd Header (src 192.x.x.x, dst 192.x.x.y)
I have created a client-server application in C. My client resides on different VM and server resides on different VM.
On server side I am using Nginx load balancer, nginx load balancer accepts request from client and then sends request to respective containers but when loadbalancer send requests to container it modifies its header(i.e source ip and destination ip) and at container when I fetch destination ip from packet is gives container ip as destination ip, what I want is how we get actual destination ip from the packet.
Client IP : 192.x.x.x
Server IP : 192.x.x.y
Loadbalancer IP : 172.17.x.x
Container IP : 172.17.x.y
Flow :
client -> loadbalacer -> container
Client Sends Header (src : 192.x.x.x, dst 192.x.x.y)
Loadbalancer Recvd Header (src : 192.x.x.x, dst 192.x.x.y)
Loadbalancer Sends Header (src 172.17.x.x, dst 172.17.x.y)
Container Recvd Header (src 172.17.x.x, dst 172.17.x.y)
What I am actually looking for :
Loadbalancer Sends Header (src 192.x.x.x, dst 192.x.x.y)
Container Recvd Header (src 192.x.x.x, dst 192.x.x.y)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果负载平衡器将请求发送到容器,则最好让
src
成为加载平衡器的IP。在您的容器中,要获取启动此请求的客户端的IP地址,请查找标题
x-forwarded-for
(在您的情况下,这将是IP192.xxxx
)。If the load balancer is sending the request to the container, it is best to let the
src
be the IP of the load balancer.In your container, to get the IP address of the client who initiated this request, look for the header
X-Forwarded-For
(in your case, this will be the IP192.x.x.x
).