Fix WordPress https error on apache and Nginx reverse proxy

Wordpress error Blocked loading mixed active content

If you have an error below when installing WordPress

Blocked loading mixed active content css

Blocked loading mixed active content js file

Add this code on wp-config.php

if ( $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) {
        $_SERVER['HTTPS']       = 'on';
        $_SERVER['SERVER_PORT'] = '443';
        define('FORCE_SSL_ADMIN', true);
}
if ( isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
        $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}

ServerDiary

ServerDiary

Leave a Reply

Your email address will not be published. Required fields are marked *