再会,
下面是我的 web 项目的架构图。
Internet --> F5 Load balancer --> Apache web server --> web application
我正在尝试让 Apache Web 服务器从负载均衡器接收来自 Internet 的用户 ip。
但是,我发现是从Apache Web Server
接收,而不是来自互联网的用户 ip。F5 ip
F5 Load balancer
因此我打开了httpd.conf
来自网络服务器并配置了X-Forwarded-For
里面的设置,以下是我在里面添加的值httpd.conf
:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
# The following line is added by me
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
# I commented this following line
#CustomLog logs/access_log combined
# The following 3 lines is added by me
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
CustomLog "logs/access_log" combined env=!forwarded
CustomLog "logs/access_log" proxy env=forwarded
我重新启动apache
服务器,但结果仍然相同。我可以知道我为配置设置的错误吗?