簡體   English   中英

X-Forwarded-For無法在Apache Web服務器中工作

[英]X-Forwarded-For not working in apache web server

美好的一天,

以下是我的Web項目的架構圖。

Internet --> F5 Load balancer --> Apache web server --> web application

我試圖使Apache Web服務器從負載平衡器接收來自Internet的用戶ip。

但是,我發現Apache Web Server正在從F5 Load balancer接收F5 ip ,而不是從Internet接收用戶ip。

因此,我從Web服務器打開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服務器,但結果仍然相同。 我可以知道我為配置設置的任何錯誤嗎?

您需要在F5負載均衡器的HTTP配置文件中啟用Insert X-Forwarded-For選項:

Local Traffic > Profiles > HTTP 

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM