Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter consultkevin

    (@consultkevin)

    For anyone else who may have the same problem:

    When you clone your site to a new domain (for staging an improvement), JetPack assigns a new blog_id thereby breaking association with JetPack’s previous stats. So, your staging site cannot be used to replace the new site without losing stats and subscribers.

    However, you can change your blog_id to match the original site and restore stats:

    (1) The blog_id is in the wp_options table’s ‘stats_options’ record:

    SELECT * FROM wp_options WHERE option_name=’stats_options’;

    • Your ‘blog_id’ is listed in PHP object serialized format. e.g. blog_id = 0123456789 is represented as:

    s:7:”blog_id”;i:0123456789;

    • Change that blog_id to your original blog_id (keeping PHP serialization format).
    • Then you must disconnect from JetPack and then reconnect JetPack (setup) and then reconnect your WP.com account.

    At that point, the stats and subscribers were restored for me.

    (2) You can also download your subscriber email list in csv format, if you are logged into the correct WP.com account:

    https://dashboard.wordpress.com/wp-admin/admin.php?page=stats&blog=BLOG_ID_HERE&blog_subscribers=csv&type=email

    There’s also a “type=wpcom” list for your WP.com followers, but it is not useful without WP.com properly linking them to their users.

    Jetpack support used to be responsive, but I have not received a reply in more than a week. I posted both in this forum and using their magic link which emails them at [email protected] and assigns a support ticket #:

    https://jetpack.com/contact-support/?rel=support&hpi=1

    Thread Starter consultkevin

    (@consultkevin)

    We are still having this problem. After further analysis, it seems that:

    (1) You only whitelisted my IP. When I go to the login page from other IPs, login is locked and it is still incorrectly reporting the server’s IP as the source of the login attempt.

    (2) Furthermore, WordPress/JetPack is the one setting php’s $_SERVER[‘REMOTE_ADDR’] to be the same as the incorrect $_SERVER[‘HTTP_X_FORWARDED_FOR’]. Those are not the same in the original environment provided by BlueHost, so that is a bug on the WordPress/JetPack side. Maybe a result of your “fix”.

    In order to compensate for BlueHost’s error and JetPack’s preference, I hacked wp-config.php to unset BlueHost’s incorrect HTTP_X_FORWARDED_FOR environment variable and in $_SERVER, so JetPack isn’t confused:

    wp-config.php:
    ————
    // 6/4/2019 11:25:25 AM [Kevin]
    // unset HTTP_X_FORWARDED_FOR because BlueHost incorrectly sets it to the SERVER’s IP rather than the client’s IP, and JetPack preferentially uses HTTP_X_FORWARDED_FOR instead of REMOTE_ADDR to block login hammering.
    // – so JetPack ends up blocking ALL logins because all logins look like they are coming from the server.
    putenv(‘HTTP_X_FORWARDED_FOR’);
    // $_SERVER was already set from the env, so we have to unset that, too:
    unset($_SERVER[‘HTTP_X_FORWARDED_FOR’]);
    // might have to unset in $_ENV, too, but php.ini isn’t loading that for me.
    ————

    It would be even better if I could unset this upstream in .htaccess (or Apache itself), but that isn’t working for me for some reason, probably due to BlueHost’s Apache’s permissions:

    .htaccess:
    ————
    # if we have mod_env and server permissions, we might be able to unset it in .htaccess:
    UnSetEnv HTTP_X_FORWARDED_FOR
    ————

    Thread Starter consultkevin

    (@consultkevin)

    Great, thanks so much, James! ??

    Also, I notice that I accidentally wrote “X-Forwarded-To” instead of “X-Forwarded-For” in the title.

    Thread Starter consultkevin

    (@consultkevin)

    Yikes! Maybe BlueHost was messing around with REMOTE_ADDR during your test because I’m still getting my local IP for REMOTE_ADDR and 162.144.179.14 for HTTP_X_FORWARDED_FOR. Checked with both a little .php test script and using the “Debug Info” plugin.

    Thread Starter consultkevin

    (@consultkevin)

    https://apologetics315.com

    Thanks, James! So, you will be changing where JetPack gets the client IP? I have BlueHost working on fixing the HTTP header, too.

    Thread Starter consultkevin

    (@consultkevin)

    Great! Thanks! ??

Viewing 6 replies - 1 through 6 (of 6 total)