简体   繁体   English

Apache负载平衡器(代理)服务器背后的真实IP

[英]Real IP behind Apache Load Balancer (Proxy) Server

I need to forward the real ip of the visitor to Apache Load Balancer. 我需要将访问者的真实IP转发给Apache Load Balancer。 I have done it on Nginx successfully by just adding following two lines: 我已经在Nginx上成功完成了它,只需添加以下两行:

proxy_set_header    X-Real-IP        $remote_addr;
proxy_set_header    X-Forwarded-For  $proxy_add_x_forwarded_for

I also have found above solution (for Nginx) on websites that explain the solution for both Apache and Nginx, but it doesn't work for Apache. 我还在网站上找到了上述解决方案(针对Nginx),该解决方案说明了针对Apache和Nginx的解决方案,但不适用于Apache。 Generally solutions are shared for Apache Servers as a back-end server. 通常,解决方案是将Apache服务器作为后端服务器共享的。 However, in my case, Apache is the load balancer. 但是,就我而言,Apache是​​负载平衡器。 I have also tried mod_rpaf but either it did not work or I couldn't apply it successfully. 我也尝试过mod_rpaf,但是它要么无法正常工作,要么无法成功应用。

When acting in a reverse-proxy mode (using the ProxyPass directive, for example), mod_proxy_http adds several request headers in order to pass information to the origin server. 当在反向代理模式下工作时(例如,使用ProxyPass指令),mod_proxy_http添加多个请求标头,以便将信息传递到原始服务器。 These headers are: 这些头是:

X-Forwarded-For The IP address of the client. X-Forwarded-For客户端的IP地址。 X-Forwarded-Host The original host requested by the client in the Host HTTP request header. X-Forwarded-Host客户端在Host HTTP请求标头中请求的原始主机。 X-Forwarded-Server The hostname of the proxy server. X-Forwarded-Server代理服务器的主机名。

https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#x-headers https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#x-headers

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM