WordPress.org

Ready to get started?Download WordPress

Forums

Visitor Maps and Who's Online
[resolved] My IP address shows up as 127.0.0.1 (7 posts)

  1. huyz
    Member
    Posted 2 years ago #

    I have my WP 3.0.5 multisite installation behind an Apache proxy, using ProxyPass.

    I've included this in my wp-config.php:

    /* Get the original remote IP (useful for comments, contact forms, and maybe stats)
     * As per http://core.trac.wordpress.org/ticket/9235
     */
    if ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) && preg_match( '/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $_SERVER['HTTP_X_FORWARDED_FOR'] ) )
       $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];

    Yet, visitor-maps still says my IP is 127.0.0.1.

  2. Mike Challis
    Member
    Plugin Author

    Posted 2 years ago #

    There is a function get_ip_address() in visitor-maps.php
    Maybe you need to modify it, I am not sure.

    Mike

  3. huyz
    Member
    Posted 2 years ago #

    Thanks for getting back to me.

    I took at look at get_ip_address(), which does favor getenv() over $_SERVER['REMOTE_ADDR']. My guess is that $_SERVER['REMOTE_ADDR'] should take precedence as that's what the core uses for comments (as http://core.trac.wordpress.org/ticket/9235 talks about) and other "contact forms" plugins use.

    So if you could swap those 2 if-statements for a future version, that would be great.

    In the meantime, I have found a workaround for my site:
    apache_setenv("REMOTE_ADDR", $_SERVER['HTTP_X_FORWARDED_FOR']);

    (strangely, putenv() doesn't work for me -- maybe because of safe_mode.)

  4. Mike Challis
    Member
    Plugin Author

    Posted 2 years ago #

    Did you try to swap those 2 if-statements and see if that works?

    safe_mode is bad, it is no longer recommended and will be removed in PHP 6

  5. huyz
    Member
    Posted 2 years ago #

    Yes it does work, but I had to swap it in all 4 places where get_ip_address() is defined.

  6. Mike Challis
    Member
    Plugin Author

    Posted 2 years ago #

    Ok, it will be changed in the next version.

  7. huyz
    Member
    Posted 2 years ago #

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic