1

I am having this problem to find unique visitors to my site. The site is deployed on AWS cloud. The first hit goes to load balancer which routes to varnish cache (type of reverse proxy) and which inturn routes to apache web server. I have the below config inside my apache conf file:

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" \"%{forensic-id}n\"" varnishcombined

CustomLog logs/access_log varnishcombined

inside my varnish file I have following: sub vcl_recv {

unset req.http.X-Forwarded-For;
set req.http.X-Forwarded-For = client.ip;

When I check my access log, I see that all requests have the load balancer IP rather than the actual IP of the client from where request has come. nfact it is the ip of the aws load balancer.

If i remove any one that is either varnish or load balancer my access log has correct entries capturing the client IP addresses.

Has anybody faced this situation?

Manguesh

4

2 回答 2

2

在 sub vcl_recv 中使用它有一个 IP 列表(包括您的 ELB 和客户端 IP)

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;
    }
}
于 2013-08-02T00:32:02.833 回答
0

好的,所以修复很简单。我所要做的就是从我的清漆配置文件中删除以下几行:

取消设置 req.http.X-Forwarded-For;设置 req.http.X-Forwarded-For = client.ip;

最初我只有 varnish 和 apache 作为后端,因此上述行是传播客户端 IP 所必需的。但是,通过在清漆代理上方添加负载均衡器,相同的行修剪了客户端 IP 传播的 http 标头,而是将负载均衡器 Ip 设置为客户端。

曼格什

于 2013-03-21T14:28:54.557 回答