WordPress.org

Support

Support » Plugins and Hacks » [Resolved] improve IP logging

[Resolved] improve IP logging

Viewing 7 replies - 1 through 7 (of 7 total)
  • I’m not the plugin author. But wanted to chip in here.

    Are you sure that the issue is with this plugin?

    To test, if the issue is only with this plugin, please do the following steps…

    1. Visit your site as non-logged-in user.
    2. Write a test comment on a blog post.
    3. Visit your site’s domainname.com/wp-admin/edit-comments.php
    4. Check the IP address of your comment.
    5. If your IP displays as localhost, then the issue is not within this plugin, but in your server setup.
    6. Delete the test comment.

    This is a good point to check. I did so and comments.php does show expected IP addresses (not just localhost). I don’t claim that this is not an artifact of my particular setup, but I have other plugins that do show the origin IP correctly.

    To be clear, this is a fairly common issue, so I’m not picking on the ARYO plugin; there are many other plugins that have the same issue. In fact I raise it only because ARYO is the best logging tool I’ve seen for my purpose (I realize there are specific security-oriented loggers, but I like the particular features of this one). I’m no expert but I think that obtaining the true IP address is just a matter of looking at the right tag, e.g. X-Forwarded-For. I’ve seen it discussed in a number of places in WP forums and elsewhere, e.g.
    https://www.benjaminwiedmann.net/wordpress-behind-reverse-proxy-fix-wrong-ip-insert-x-forwarded-for-ip.html

    Okay. I just tested in a demo environment that runs Varnish. The visitors’ IPs are logged correctly by this plugin. However, my setup may differ from yours.

    Anyway, this plugin does use $_SERVER[‘REMOTE_ADDR’], in classes/class-api.php, at line number 31, to collect the visitor’s IP.

    @plugin‘s authors:

    There are multiple ways to collect the correct IP. The one recommended way is already mentioned in the article linked above by @mpd2002. There is an alternative way that uses preg_match, but is more accurate, IMO.

    Plugin Author Yakir Sitbon
    Participant

    @kingyes

    Hi guys..
    Thank for your comment.

    @mpd2002,
    I just want to check, what you get from this code (put it on your functions.php, in dev area):

    function aryo_test_get_ip() {
        var_dump( $_SERVER['HTTP_X_FORWARDED_FOR'] );
    }
    add_action( 'init', 'aryo_test_get_ip' );

    Can you paste here the result?

    Plugin Author Yakir Sitbon
    Participant

    @kingyes

    Hi guys..
    Thank for your comment.

    @mpd2002,
    I just want to check, what you get from this code (put it on your functions.php, in dev area):

    function aryo_test_get_ip() {
        var_dump( $_SERVER['HTTP_X_FORWARDED_FOR'] );
    }
    add_action( 'init', 'aryo_test_get_ip' );

    Can you paste here the result?

    Plugin Author Maor Chasen
    Member

    @maor

    Thanks for your help, guys.

    Did anyone got to test Yakir’s code by any chance?

    Cheers

    Plugin Author Yakir Sitbon
    Participant

    @kingyes

    Now our plugin have full support for your issue. Thanks.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] improve IP logging’ is closed to new replies.