Apache2 前面加上 Load Balancer (F5 Big IP LTM),走得就類似 Reverse Proxy 的模式,會由 F5 將 X-Forwarded-For 轉送到 Apache,要怎麼設定格式才能跟原始 combined 一樣呢?
Apache2 抓取 Load Balancer Client IP 的設定
- vim /etc/apache2/apache2.conf # 下述 combined_forwarded 可以直接換成 combined,原本的設定就都不需要更動
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined_forwarded CustomLog /var/www/project/log/access.log combined_forwarded
- sudo apache2ctl configtest
- sudo systemctl restart apache2
相關網頁
- Reflection: Client IP Filtering in Weblogic and Apache through Load Balancer (F5 Big IP LTM)
- F5 Big-IP, Apache logs and client IP
Save