Magento – WordPress Integration behind load balancer

  • Unknown's avatar

    Bit about me for context: I’m a PHP constant, currently working on a Magento Webshop for my client. I was asked to integrate using the Fishpig – Magento WordPress Integration module.

    My client has a Magento installation behind a load balancer (multiple frontends) and forces all connections to be secure (HTTPS). This is however not the issue.

    WordPress detects the scheme by looking at the $_SERVER[‘HTTPS’] and optionally the $_SERVER[‘SERVER_PORT’] globals. The load balancer however passes the scheme in the $_SERVER[‘HTTP_X_PROTOCOL’]. Hence the modification I had to do in the wp/wp-includes/load.php file:

    
    /**
     * Determines if SSL is used.
     *
     * @since 2.6.0
     * @since 4.6.0 Moved from functions.php to load.php.
     *
     * @return bool True if SSL, otherwise false.
     */
    function is_ssl() {
        if ( isset( $_SERVER['HTTP_X_PROTOCOL'] )
                && ( $_SERVER['HTTP_X_PROTOCOL'] === 'HTTPS' ) ) {
            $_SERVER['HTTPS'] = 'on';
        }
        if ( isset( $_SERVER['HTTPS'] ) ) {
            if ( 'on' == strtolower( $_SERVER['HTTPS'] ) ) {
                return true;
            }
     
            if ( '1' == $_SERVER['HTTPS'] ) {
                return true;
            }
        } elseif ( isset( $_SERVER['SERVER_PORT'] ) && ( '443' == $_SERVER['SERVER_PORT'] ) ) {
            return true;
        }
        return false;
    }
    

    Feel free to integrate and present kudos.

  • Hi there,

    You have posted in the forums for the hosting platform, WordPress.com. We’re not the same thing as the open source WordPress software you’re working with, which can be found on WordPress.org.

    You can find the support forums for that software at https://wordpress.org/support/forums/

    If you’ve made modifications to FishPig’s plugin or theme, and wish to submit a patch to have those modifications included in the plugin/theme itself, please contact FishPig directly for their process for doing that.

  • Unknown's avatar
  • The topic ‘Magento – WordPress Integration behind load balancer’ is closed to new replies.