matomo-log-analytics
matomo-log-analytics copied to clipboard
Detecting if website is using cloudflare
Hello,
does someone experienced issues with importing logs from sites which are using CloudFlare? I'm hosting services provider which is using Piwik as statistics application for clients websites. Some of clients are using CloudFlare for their websites. Hosting services are Windows IIS server based with added "CF-Connecting-IP" log param. If client is using CloudFlare at the end of each line in IIS website log file is being shown real customer IP address. If not then this column is empty. I'm wondering if someone else experienced similar scenario? IMHO this could be handled by having some condition statements like if "CF-Connecting-IP" contains IP then use it as viewer IP address else use "c-ip" column.
What do you think about it?
Thanks
This can be hacked (and probably done in much better way) by adding:
'CF-Connecting-IP': '"?(?P<ip2>[\w*.:-]*)"?'
to fields array
right after:
'time-taken': '(?P<generation_time_secs>[.\d]+)',
and then just replace hit.ip field by using:
if not format.get('ip2'):
hit.ip = format.get('ip')
else:
hit.ip = format.get('ip2')
try:
hit.length = int(format.get('length'))
@grzech1983
- Would you mind posting a pull request with your change? It looks legitimate to me
- Could you paste here a short example log file from Cloudflare?