Want to subscribe to topics you're interested in?
Become a Member

cloudflare wrong ip

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Oxide, May 13, 2017.

  1. Oxide

    Oxide Active Member

    502
    29
    28
    Mar 19, 2015
    Ratings:
    +54
    Local Time:
    1:44 AM
    Code:
    set_real_ip_from 103.21.244.0/22;
    set_real_ip_from 103.22.200.0/22;
    set_real_ip_from 103.31.4.0/22;
    set_real_ip_from 104.16.0.0/12;
    set_real_ip_from 108.162.192.0/18;
    set_real_ip_from 141.101.64.0/18;
    set_real_ip_from 162.158.0.0/15;
    set_real_ip_from 172.64.0.0/13;
    set_real_ip_from 173.245.48.0/20;
    set_real_ip_from 188.114.96.0/20;
    set_real_ip_from 190.93.240.0/20;
    set_real_ip_from 197.234.240.0/22;
    set_real_ip_from 198.41.128.0/17;
    set_real_ip_from 199.27.128.0/21;
    real_ip_header CF-Connecting-IP;
    It's been happening on all of my servers. It seems like it does not return correct IP.

    Example: 108.162.219.104 appeared. I had to add this PHP code to get it to work:

    Code:
    if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
      $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
    }
    Any reason why? maybe invalid IP Range..?
     
  2. eva2000

    eva2000 Administrator Staff Member

    29,044
    6,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,785
    Local Time:
    1:44 AM
    Nginx 1.13.x
    MariaDB 5.5
    what are you trying to do ? for Centmin Mod Nginx vhost just use 123.09beta01's tools/csfcf.sh to automate it :)
     
  3. Oxide

    Oxide Active Member

    502
    29
    28
    Mar 19, 2015
    Ratings:
    +54
    Local Time:
    1:44 AM
    Get the REAL IP like older versions
     
  4. eva2000

    eva2000 Administrator Staff Member

    29,044
    6,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,785
    Local Time:
    1:44 AM
    Nginx 1.13.x
    MariaDB 5.5
    123.09beta01's tools/csfcf.sh works fine for me :)

    just be sure to uncomment include line in your vhost
    Code (Text):
      # uncomment cloudflare.conf include if using cloudflare for
      # server and/or vhost site
      include /usr/local/nginx/conf/cloudflare.conf;
    
     
  5. Oxide

    Oxide Active Member

    502
    29
    28
    Mar 19, 2015
    Ratings:
    +54
    Local Time:
    1:44 AM
    All that does, is commenting out the hash from cloudflare.conf then loading it? Wouldn't be much of a difference doing it manually :/ It only happened to specific users, for example someone from the US that was on Phone.
     
  6. eva2000

    eva2000 Administrator Staff Member

    29,044
    6,590
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,785
    Local Time:
    1:44 AM
    Nginx 1.13.x
    MariaDB 5.5
    csfcsf.sh just automates the manual steps and if you setup cronjob regularly checks for new cloudflare ips to update your nginx and csf firewall whitelisting automatically

    have you contacted cloudflare tech support to see what the issue is for those specific users ?