我在varnish后面配置了apache2,并尝试通过日志读取添加统计信息(piwik)
然而,piwik抱怨日志“格式错误”......而且正确:
89.79.******, 89.79.****** - - [31/Mar/2014:12:50:05 +0200] "GET / HTTP/1.1" 200 16310 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36"
正如您所看到的那样,它会将两次相同的ip记录为主机...
in varnish .vcl我有:
remove req.http.X-Forwarded-For;
set req.http.X-Forwarded-For = client.ip;
并在apache2 vhost中:
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" varnishcombined
CustomLog ${APACHE_LOG_DIR}/e***o-access.log varnishcombined
然而它仍然记录了两次ip ...
我能做些什么来防止这种情况?
答案 0 :(得分:0)
我最终使用了mod_cloudflare: https://support.cloudflare.com/hc/en-us/articles/200170796-How-do-I-install-mod-cloudflare-on-Apache-
并将可信代理设置为127.0.0.1 + log combined
如果有人有更好的解决方案......