• Resolved Zee

    (@laserjobs)


    Noticing that a few review IPs come through as 127.0.0.1 and not the actual IP address, even though I am using HTTP_X_FORWARDED_FOR in wp-config with Varnish. Also in the Console in the tools menu every SPAM comment is only showing 127.0.0.1
    [ip_address] => 127.0.0.1

    Here is what is I am using in wp-config.php to relay the actual IP

    
    if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { 
    $xffaddrs = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']); 
    $_SERVER['REMOTE_ADDR'] = $xffaddrs[0]; 
    }
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    Site Reviews does not currently handle proxy headers in its IP detection, it only looks for remote-addr and cloudflare headers.

    v3.6.0 will add proxy header support.

    • This reply was modified 5 years, 7 months ago by Gemini Labs.
    Plugin Author Gemini Labs

    (@geminilabs)

    @laserjobs,

    Since it is taking much longer than anticipated to release v3.6 (the next version will actually now be v4.0), here is how you can fix the issue yourself (provided you feel comfortable with making a small edit to one of the plugin files):

    The file to edit is found here:

    /wp-content/plugins/site-reviews/plugin/Helper.php
    

    Search for this:

    Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR
    

    And replace with this:

    Whip::ALL_METHODS
    
    Thread Starter Zee

    (@laserjobs)

    Actually it seems to be only in the spam comments in the log files where this happens. For some reason when I do the file changes all the IPs become 127.0.0.1

    The current setting for the real IP in WP config is HTTP_X_REAL_IP.
    HTTP_X_FORWARDED_FOR will also work.

    if($_SERVER['HTTP_X_REAL_IP']){
    $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REAL_IP'];
    }

    I tried Whip::PROXY_HEADER but that gave me 127.0.0.1 as well

    Whip::REMOTE_ADDR works for the most part except for the spam comments caught in the log files.
    https://github.com/Vectorface/whip

    • This reply was modified 5 years, 3 months ago by Zee.
    • This reply was modified 5 years, 3 months ago by Zee.
    Plugin Author Gemini Labs

    (@geminilabs)

    @laserjobs

    I have three things to try, would you try each of them in turn and let me know the results?

    First, copy the getIpAddress function from the unreleased v4.0 and paste it in the v3.5 plugin, replacing the existing function: https://github.com/pryley/site-reviews/blob/develop/plugin/Helper.php#L233-L257

    Then please try each of the following separately (even if one is successful):

    1. Add the following snippet using the Code Snippets plugin:

    add_action('site-reviews/whip', function ($whip) {
        $whip->addCustomHeader('HTTP_X_REAL_IP');
    });

    2. Undo step 1, then replace the following line:

    Whip::CUSTOM_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR
    

    With this:

    Whip::PROXY_HEADERS | Whip::CLOUDFLARE_HEADERS | Whip::REMOTE_ADDR
    

    3. Keep step 2, but now add the following snippet using the Code Snippets plugin:

    add_filter('site-reviews/whip/whitelist', function ($whitelist) {
        $whitelist[\GeminiLabs\Vectorface\Whip\Whip::PROXY_HEADERS] = [
            \GeminiLabs\Vectorface\Whip\Whip::IPV4 => ['127.0.0.1'],
            \GeminiLabs\Vectorface\Whip\Whip::IPV6 => ['::1'],
        ];
        return $whitelist;
    });
    Thread Starter Zee

    (@laserjobs)

    Soory but it is not possible to test this right now due to some time constraints. I am also thinking the issue is with Akismet Integration only not the general plugin.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘IP sometimes comes through as 127.0.0.1 (localhost)’ is closed to new replies.