HAProxy+squidサーバ x 2で負荷分散したら
上位squid 3.1.xをHAProxyでロードバランスしている状態で
上位squidのaccess.logに接続元の下位squidのIPアドレスが取れず、上位squid自身のIPが記録されて困ってしまいましたが、ネットを探したところ、このようにするとOKでした。
- haproxy.cfgには
option http-server-close
option forwardfor
を追加する。
- 上位のsquid.confには
# x-forwarded-for log
acl internal_proxy srcdomain 下位squidのドメイン名
follow_x_forwarded_for allow localhost
follow_x_forwarded_for allow internal_proxy
acl_uses_indirect_client on
log_uses_indirect_client on
とするとOKでした。
ただし、上位squidは「--enable-follow-x-forwarded-for」をオプションつけてビルドしてあることが前提のようです。