Varnish Client IP not logging in Apache Logs

前端 未结 3 484
你的背包
你的背包 2020-12-31 22:33

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

3条回答
  •  没有蜡笔的小新
    2020-12-31 23:09

    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;
      }
    }
    

    In your vcl_recv{}.

提交回复
热议问题