Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED Visitor IPs in Logs using cloudflare

Discussion in 'General Discussion' started by domainerq, Feb 24, 2017.

Tags:
  1. domainerq

    domainerq Member

    Joined:
    Feb 22, 2017
    Messages:
    14
    Likes Received:
    4
    Trophy Points:
    3
    Location:
    Peru
    cPanel Access Level:
    Root Administrator
    Hello, i am trying to get in Cpanel log the real ip of my visitor, but for some reason, that's not working.

    I have installed - CENTOS 6.8 x86_64 / WHM 62.0 / easyapache 4

    Here the steps that i have done.

    1. I installed whm from scratch.
    2. I have added mod_ remoteip . (Also ,before i tried installing mod_cloudflare but there was several problems after the installation) , so i prefer not to use 3rd party modules.
    3. i rebuilt easyapache 4.

    4. i have added the code below , in /etc/apache2/conf/httpd.conf


    <IfModule !mod_remoteip.c>
    LoadModule remoteip_module modules/mod_remoteip.so
    </IfModule>

    <IfModule mod_remoteip.c>
    # CloudFlare Header
    RemoteIPHeader CF-Connecting-IP

    # Trusted Proxy List
    # note - using RemoteIPTrustedProxy instead of RemoteIPInternalProxy
    # note - RemoteIPTrustedProxy does NOT trust Header provided private intranet addresses (local and LAN addresses)
    # note - RemoteIPInternalProxy is a security risk when using an external Proxy

    # CloudFlare IPv4 Address Ranges
    RemoteIPTrustedProxy 103.21.244.0/22
    RemoteIPTrustedProxy 103.22.200.0/22
    RemoteIPTrustedProxy 103.31.4.0/22
    RemoteIPTrustedProxy 104.16.0.0/12
    RemoteIPTrustedProxy 108.162.192.0/18
    RemoteIPTrustedProxy 141.101.64.0/18
    RemoteIPTrustedProxy 162.158.0.0/15
    RemoteIPTrustedProxy 172.64.0.0/13
    RemoteIPTrustedProxy 173.245.48.0/20
    RemoteIPTrustedProxy 188.114.96.0/20
    RemoteIPTrustedProxy 190.93.240.0/20
    RemoteIPTrustedProxy 197.234.240.0/22
    RemoteIPTrustedProxy 198.41.128.0/17
    RemoteIPTrustedProxy 199.27.128.0/21

    # CloudFlare IPv6 Address Ranges
    RemoteIPTrustedProxy 2400:cb00::/32
    RemoteIPTrustedProxy 2405:8100::/32
    RemoteIPTrustedProxy 2405:b500::/32
    RemoteIPTrustedProxy 2606:4700::/32
    RemoteIPTrustedProxy 2803:f800::/32
    </IfModule>

    5. I restarted httpd .
    6. i have added in a php file.

    if($_SERVER["HTTP_X_FORWARDED_FOR"]){
    echo "Proxy ip : {$_SERVER['REMOTE_ADDR']}<br>";
    echo "Real IP : {$_SERVER['HTTP_X_FORWARDED_FOR']}";
    }else{
    echo "Real IP: {$_SERVER['REMOTE_ADDR']}";}
    ?>

    And the value of HTTP_X_FORWARDED_FOR it is the same than REMOTE_ADDR , so i can see my real ip in both of them, then I open the cpanel logs and this still shows the ip's cloudflare.

    Is there something else that i have to do?

    Thanks.
     
    #1 domainerq, Feb 24, 2017
    Last edited: Feb 24, 2017
  2. domainerq

    domainerq Member

    Joined:
    Feb 22, 2017
    Messages:
    14
    Likes Received:
    4
    Trophy Points:
    3
    Location:
    Peru
    cPanel Access Level:
    Root Administrator
    I have solved the problem! i forgot to configure the LogFormat.
     
    cPanelMichael and Infopro like this.
  3. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    16,170
    Likes Received:
    370
    Trophy Points:
    583
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
    Thanks for updating your thread.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice