1

I recently set up my home server to use CloudFlare (Ubuntu Server 16.04.1). Everything seems to work fine and it's awesome.

However, I have a major problem, every time I check my access.log in Apache I realize that CloudFlare logs are simply not showing up there or updating. If I connect directly to my IP address, the access.log is updated immediately but if I access my site through the CloudFlare domain then the access.log file doesn't update at all.

I'm really confused as I don't understand how this is possible, I thought all CloudFlare does is change the incoming IP, why would it stop my server from logging it?

Edit: If it helps I also got a bunch of these logs added to my access.log file, no idea if they are related or not:

::1 - - [12/Dec/2016:13:37:26 +0000] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.18 (Ubuntu) (internal dummy connection)"
::1 - - [12/Dec/2016:13:37:27 +0000] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.18 (Ubuntu) (internal dummy connection)"
::1 - - [12/Dec/2016:13:37:28 +0000] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.18 (Ubuntu) (internal dummy connection)"

2 Answers 2

0

There are two main potential issues here:

  1. You're hitting a cached resource, which isn't reaching your origin server. If you've set a "Cache Everything" Page Rule, Cloudflare will also cache static HTML. The CF-Cache-Status header indicates whether Cloudflare is caching a resource.
  2. You're not recording visitor IPs correctly. On Apache, you should be sure to install the Mod_Cloudflare extension to ensure you are recording visitor IPs correctly in your logs.
1
  • Starting from Ubuntu 18.04 LTS, Cloudflare no longer updates and supports mod_cloudflare.
    – sotirov
    Oct 26, 2023 at 21:23
0

When your website traffic is routed through the Cloudflare network, they act as a reverse proxy. As a result, when responding to requests and logging them, your origin server returns a Cloudflare IP address.

You can log the original visitor IP address in Apache2 by enabling mod_remoteip.

  1. Enable the module:

    sudo a2enmod remoteip
    sudo service apache2 restart
    
  2. Edit your vhost config file. The default file is /etc/apache2/sites-available/000-default.conf. Between <VirtualHost *:80> and </VirtualHost>, add the following line:

    RemoteIPHeader CF-Connecting-IP
    

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .