Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a number of sites using cloudflare as a CDN with the apache mod_cloudflare installed to restore original visitor IPs to my server logs. Does anyone know of a way I can make the logs identify which requests came via cloudflare and which didn't?

share|improve this question
up vote 1 down vote accepted

I took a look through the source code for mod_cloudfare.c: https://github.com/cloudflare/CloudFlare-Tools/blob/master/mod_cloudflare.c. It appears that the module logs the information you are looking for:

                  ? "Using %s as client's IP by proxies %s"
                  : "Using %s as client's IP by internal proxies",
              conn->proxied_ip, conn->proxy_ips);

Based on this code, it appears this information will appear in the error log. It does not appear that module has any facility for modifying other parts of the request to identify modified entries in the access_log.

If there are headers that cloudflare sends that you wish to log, you can append them to your access_log using %{Foobar}i in the log file definition where "Foobar" is the name of the header. For example you might choose your log format as:

"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" %{CF-Connecting-IP}i
share|improve this answer
Cloudflare do add some custom HTTP headers - would there be an easy way of looking for these and logging them? – cbull Mar 13 '13 at 10:50
You can log custom headers. I updated my answer with information. – Stephen Ostermiller Mar 13 '13 at 10:59

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.