This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 4

Cloudflare Help - Restore original IP Address


  1. CMather
    Member

    Hello,

    We currently use Cloudflare CDN for our website.
    With cloudflare they have a module called mod_cloudflare which enables the correct IP address of the visitor instead of seeing cloud flares IP.

    We are unable to install this module on the server however cloudflare have given us this simple code to add to the script to read the correct IP address instead of the CDN network IP address.

    Link:
    https://support.cloudflare.com/hc/en-us/articles/200170876-I-can-t-install-mod-cloudflare-and-there-s-no-plugin-to-restore-original-visitor-IP-What-should-I-do-

    Code:
    <?php if (isset($_SERVER['HTTP_CF_CONNECTING_IP']))
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];
    ?>

    "If you can't install mod_cloudflare, or if there is no plugin available for your CMS platform to restore original visitor IP, you would want to put this code in your site in or before the <body>:"

    We want to add this to Machform as we want the correct IP address to show in the forms instead of the CDN network.

    Where is the best place to place this code so all forms that request the IP will be displayed correctly?

    thanks.

    Posted 9 years ago #
  2. CMather
    Member

    If anyone is looking to restore the original IP address from Cloudflare CDN, we got it working by adding the following code to config.php

    /** CloudFlare Add to Restore IP Address **/
    if (isset($_SERVER['HTTP_CF_CONNECTING_IP']))
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP'];

    We added it before the ?> end tag
    Now when the email is sent the correct IP address is sent with the email instead of cloudflare server IP address.

    Posted 9 years ago #

RSS feed for this topic

Reply