Varnish Client IP not logging in Apache Logs

前端 未结 3 473
你的背包
你的背包 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条回答
  •  梦毁少年i
    2020-12-31 23:03

    Add this line to your vcl

    sub vcl_recv {
      # Add a unique header containing the client address
      remove req.http.X-Forwarded-For;
      set    req.http.X-Forwarded-For = client.ip;
    
    }
    

    Then change the logformat of apache

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

    And now in your Virtualhost

    
      ServerName www.abc.com
    
      CustomLog /var/log/httpd/www.abc.com/access.log varnishcombined
    
    
    

提交回复
热议问题