0
我有Tomcat的8配置背後IIS 8.還我啓用CDN服務。的Tomcat RemoteIpValve配置與CDN
主機,使RemoteIpValve爲
<Valve className="org.apache.catalina.valves.RemoteIpValve"
remoteIpHeader="x-forwarded-for"
proxiesHeader="x-forwarded-by"
protocolHeader="x-forwarded-proto"/>
日誌顯示爲
org.apache.catalina.valves.RemoteIpValve.invoke Incoming request /api/service/dealer/getStates with originalRemoteAddr '127.0.0.1', originalRemoteHost='127.0.0.1', originalSecure='false', originalScheme='http' will be seen as newRemoteAddr='121.244.190.83', newRemoteHost='121.244.190.83', newScheme='http', newSecure='false'
訪問日誌配置
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="web.hyundai.co.in_access_log" suffix=".txt"
pattern="x-forwarded-for : %{x-forwarded-for}i %h %t "%r" %s %b"/>
而且在訪問日誌
x-forwarded-for : 121.243.37.18, 121.244.190.83 127.0.0.1 [01/Mar/2017:09:02:52 +0530] "GET /api/service/dealer/getStates HTTP/1.1" 200 436
現在Tomcat沒有拿起實際的客戶機IP 121.243.37.18,而不是它選擇CDN服務器IP。我無法將CDN服務器IP作爲代理添加,因爲CDN邊緣服務器將會很多。如何配置Tomcat來得到正確的遠程IP地址
的x轉發是給逗號分隔IP包括實際的客戶端IP和IP CDN。但出於某種原因Tomcat的RemoteIPValve使用的最後一個值(CDN IP),而不是實際的客戶端IP。所以我要求提供的CDN添加客戶頭文件true-client-ip並傳遞實際的遠程客戶端IP並且工作。 – Mukun