WordPress.org

Ready to get started?Download WordPress

Forums

iThemes Security (formerly Better WP Security)
Netscalers proxy loadbalancer with SSL and IPv6 (1 post)

  1. tradik
    Member
    Posted 1 year ago #

    Plugin is reading address from $_SERVER['REMOTE_ADDR'] in inc/secure.php
    It should have detection of proxy behind like:

    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR'];

    To get SSL need to have this line added when using loadbalancer/netscaler/proxy:
    if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') $_SERVER['HTTPS']='on';

    To get nice working SSL I'll suggest to install plugin 'Force non-SSL'.

    IPv6 is failing on 32-bit OS to solve that simply replace ip2long into :
    function ip2bin($ip)
    {
    if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false)
    return base_convert(ip2long($ip),10,2);
    if(filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false)
    return false;
    if(($ip_n = inet_pton($ip)) === false) return false;
    $bits = 15; // 16 x 8 bit = 128bit (ipv6)
    while ($bits >= 0)
    {
    $bin = sprintf("%08b",(ord($ip_n[$bits])));
    $ipbin = $bin.$ipbin;
    $bits--;
    }
    return $ipbin;
    }

    function bin2ip($bin)
    {
    if(strlen($bin) <= 32) // 32bits (ipv4)
    return long2ip(base_convert($bin,2,10));
    if(strlen($bin) != 128)
    return false;
    $pad = 128 - strlen($bin);
    for ($i = 1; $i <= $pad; $i++)
    {
    $bin = "0".$bin;
    }
    $bits = 0;
    while ($bits <= 7)
    {
    $bin_part = substr($bin,($bits*16),16);
    $ipv6 .= dechex(bindec($bin_part)).":";
    $bits++;
    }
    return inet_ntop(inet_pton(substr($ipv6,0,-1)));
    }

    Thanks,

    http://wordpress.org/extend/plugins/better-wp-security/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.