Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#40710 closed enhancement (duplicate)

Improvement ssl detection

Reported by: lriaudel's profile lriaudel Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Bootstrap/Load Keywords:
Focuses: Cc:

Description

In some case, is_ssl() don't work fine : For HTTP_X_FORWARDED_PROTO.
exemple :
https://forums.ouvaton.coop/t/https-et-port-443-avec-wordpress/1074/3

Here a proposition :

<?php
function is_ssl() {
        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;
        }
        elseif ( isset($_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] )
                return true;
        }
        return false;
}

Attachments (1)

is_ssl_proto.diff (565 bytes) - added by lriaudel 8 years ago.
function is_ssl

Download all attachments as: .zip

Change History (2)

@lriaudel
8 years ago

function is_ssl

#1 @ocean90
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
  • Version 4.7.4 deleted

Hello @lriaudel, thanks for your report, it's something that comes up often:

#15733
WordPress Installation behind reverse-proxy ssl redirect loop
#19654
Allow overload of is_ssl() via a filter
#25222
Detect https correctly when behind a proxy/loadbalancer
#31288
IS_SSL should check return true for SSL Terminated load balancing
#31439
is_ssl not compatible with server - option for filter or hook
#32354
is_ssl() does not work on cloud hosting
#33730
ssl is not detecting for cloudflare
#34298
Amazon LB SSL / HTTP_X_FORWARDED_PROTO
#34912
wp-admin/load-styles.php not serving multiple assets over HTTPS
#39659
Offloaded SSL Detection
#40710
Improvement ssl detection
#57125
custom changes to wp-includes/functions.php overwritten by automatic upgrades, breaking Cloudflare or squid frontend


Please take a look at #31288 which provides information on how to solve this for your environment.

Note: See TracTickets for help on using tickets.