configuration清漆用IP地址写apache错误日志

我正在运行Varnish的Web服务器上安装fail2ban。 许多“监狱”需要访问Apache / PHP错误日志。

我遇到的一个问题是,日志文件中的IP地址的所有引用都是127.0.0.1。

我通过运行以下命令解决了有关access.log的这个问题:

varnishncsa -a -w /var/log/varnish/access.log -D -P /var/run/varnishncsa.pid 

是否有可能做类似的日志中出现:/var/log/apache/*_error.log?

谢谢

将以下内容添加到您的/etc/varnish/default.vcl

 sub vcl_recv { remove req.http.X-Forwarded-For; set req.http.X-Forwarded-For = client.ip; } 

更新您的apacheconfiguration,将您的CustomLog更改为以下内容:

 LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" varnishcombined CustomLog /var/log/example.com-access_log varnishcombined 

有关更多信息,请查看此页面: http : //www.techinfobest.com/getting-real-client-ip-through-varnish/