Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rackspace Load Balancer with SSL Termination issue #34

Closed
fracasula opened this issue Aug 20, 2014 · 1 comment
Closed

Rackspace Load Balancer with SSL Termination issue #34

fracasula opened this issue Aug 20, 2014 · 1 comment

Comments

@fracasula
Copy link

Hi,

As mentioned in the title my web server is behind a Rackspace load balancer with SSL termination, it means that the data between the load balancer and the local servers travels unencrypted (but we're still on a secure connection!).
For some reason your isSsl() is not working as expected, it returns false. Therefore the plugin doesn't work. I wrote a little temporary hack that let me use your plugin though. It consists on returning the is_ssl() value directly:

/**
 * Checks if the current page is SSL
 *
 * @param none
 * @return bool
 */
public function isSsl() {
    if (is_ssl()) {
        return true;
    }

    // Some extra checks for Shared SSL
    if ( is_ssl() && strpos($_SERVER['HTTP_HOST'], $this->getHttpsUrl()->getHost()) === false && $_SERVER['SERVER_ADDR'] != $_SERVER['HTTP_HOST'] ) {
        return false;
    } else if ( isset($_SERVER['HTTP_CF_VISITOR']) && strpos($_SERVER['HTTP_CF_VISITOR'], 'https') ) {
        return true;
    } else if ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https' ) {
        return true;
    } else if ( $this->getSetting('ssl_host_diff') && !is_ssl() && isset($_SERVER['HTTP_X_FORWARDED_SERVER']) && $this->getHttpsUrl()->getHost() == $_SERVER['HTTP_X_FORWARDED_SERVER'] ) {
        return true;
    } else if ( $this->getSetting('ssl_host_diff') && !is_ssl() && $this->getHttpsUrl()->getHost() == $_SERVER['HTTP_HOST'] && ( $this->getHttpsUrl()->getPort() <= 0 || $_SERVER['SERVER_PORT'] == $this->getHttpsUrl()->getPort() ) && strpos($_SERVER['REQUEST_URI'], $this->getHttpsUrl()->getPath()) !== false ) {
        return true;
    }

    return is_ssl();
}

Basically the native wordpress is_ssl() function works fine for me and it detects if the current session is really SSL or not. Please tell me if you may need further information.

@headstash
Copy link
Collaborator

headstash commented Dec 29, 2017

You could achieve this modularly with the code below, that way you can safely update the plugin without losing your modification.

function is_ssl_force_ssl( $force_ssl, $post_id = 0, $url = '' ) {
	return is_ssl();
}

add_filter('force_ssl', 'is_ssl_force_ssl', 10, 3);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants