清漆客户端 IP 未登录 Apache 日志 [英] Varnish Client IP not logging in Apache Logs
问题描述
我已经用 Apache 配置了 Varnish 3,它运行得非常好.但是,我无法将客户端 ip 登录到 Apache 日志中.我尝试了一些解决方案,但没有运气.现在我的 Apache 访问日志文件记录的是服务器 IP 而不是客户端 IP 地址.
I've configured Varnish 3 with Apache and it is running perfectly alright. However i'm unable to get the Client ip logged in Apache logs. I tried a few solutions googling around with no luck. Right now my Apache access log file is logging the server IP instead of client IP addresses.
以下是我的配置供您考虑:
Here are my configurations for your kind consideration:
Varnish VCL: (/etc/varnish/default.vlc): http://pastebin.com/PuBqZ6fx
Varnish VCL: (/etc/varnish/default.vlc): http://pastebin.com/PuBqZ6fx
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/httpd.conf
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" 清漆组合
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" varnishcombined
...... 其他的东西 .....ErrorLog 日志/fr-error-logCustomLog 日志/fr-custom-log varnishcombined...... 其他的东西 .....
...... Other Stuff ..... ErrorLog logs/fr-error-log CustomLog logs/fr-custom-log varnishcombined ...... Other Stuff .....
注意:安装的 Varnish 版本是 varnish-3.0.2-1.el5.x86_64
Note: Varnish Version installed is varnish-3.0.2-1.el5.x86_64
谢谢.拉希尔
推荐答案
我认为您的 pastebin 示例中有一个有效的配置,这实际上应该可以解决问题:
I think you've had a working config in your pastebin example, this should actually do the trick:
if (req.restarts == 0) {
if (req.http.X-Forwarded-For) {
set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
}
在您的 vcl_recv{} 中.
In your vcl_recv{}.
这篇关于清漆客户端 IP 未登录 Apache 日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!