1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Cloudflare & IP checking

Discussion in 'Add-on Requests [Archive]' started by Caelum, Feb 14, 2011.

  1. Caelum

    Caelum Well-Known Member

    Yeah, basically, I've been using Cloudflare for a while now, and liking it. Trouble is, because it fuctions as a reverse proxy of sorts, all IPs come from Cloudflare's servers. That is, when I check a user's IP, the only IP that's been recorded will be one of Cloudflare's. Which doesn't particularly help when IP banning. :p

    Long story short, if anyone could fix up a quick XF mod that fixes that, I'd love you to death (in a non-creepy, platonic, non-fatal sort of way). Essentially, something like this, except for XF.

    Thanks ;)
  2. pie

    pie Member

    was nobody able to sort this, or was it resolved elsewhere?
  3. James

    James Well-Known Member

    I think from the top of my head that the quick fix was to put this into config.php:

    Caelum likes this.
  4. SteveL

    SteveL Member


    I, like many people, really dont understand exactly what that snip of coding does. Could you explain what it does or how to use it? Do you add known ip's in it somewhere? Just looking at it as is really creates more confusion for me than it does solutions.

  5. James

    James Well-Known Member

    When a visitor connects to your server, it shows that they are connecting via Cloudflare's servers because of the way Cloudflare works. Because of this, Cloudflare sends the user's IP address in a header when they connect, allowing you to use it.

    This snippet of code checks if there's an IP in the header (HTTP_CF_CONNECTING_IP) and if there is, it assigns their IP address to the standard IP variable (REMOTE_ADDR) so that your software can show their actual IP and not the IP of Cloudflare's servers.
  6. SteveL

    SteveL Member

    Nice!! Thank you.
    James likes this.
  7. James

    James Well-Known Member

    EDIT: If you see here, Mike used a different code. I'm not sure if my code works, but you'll have a warmer heart knowing this one was provided by Mike:
    if (isset($_SERVER['HTTP_CF_CONNECTING_IP']))
  8. Caelum

    Caelum Well-Known Member

    Thanks James :)
  9. Tyson

    Tyson Member

    I gather if your using it, that cloudflare must make a noticeable speed difference.

    Are there any Negatives to using Cloudflare?
  10. Caelum

    Caelum Well-Known Member

    Not really. There's false positives in their threat detection, but people can be whitelisted & it's possible to have your security settings so low no false positives occur anyway.
    If you were already using another CDN, using Cloudflare would probably be excessive, but other than that, no drawbacks I can think of. ;)
  11. Spenser

    Spenser Active Member

    Sounds interesting...
  12. Tyson

    Tyson Member

    Ive just switched over to a cloud server and my site is running alot quicker now than it was on my vps + cloudflare.

    Loving it :)
  13. Wuebit

    Wuebit Well-Known Member

    Yup it's great and damon gives awesome support here on xf

Share This Page