code: public static function getRemoteAddr()
      {
          // This condition is necessary when using CDN, don't remove it.
          if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER) && $_SERVER['HTTP_X_FORWARDED_FOR'] &&
              (!array_key_exists('REMOTE_ADDR', $_SERVER) || preg_match('/^127\./', trim($_SERVER['REMOTE_ADDR'])) ||
                  preg_match('/^172\.16\./', trim($_SERVER['REMOTE_ADDR'])) ||
                  preg_match('/^192\.168\./', trim($_SERVER['REMOTE_ADDR'])) || preg_match('/^10\./', trim($_SERVER['REMOTE_ADDR'])))
          ) {
              if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',')) {
                  $ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
  
                  return $ips[0];
              }
  
              return $_SERVER['HTTP_X_FORWARDED_FOR'];
          }
  
          return $_SERVER['REMOTE_ADDR'];
      }
docs: Get the server variable REMOTE_ADDR, or the first ip of HTTP_X_FORWARDED_FOR (when using proxy)
  
  @return string $remote_addr ip of client