Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#33730 closed defect (bug) (duplicate)

ssl is not detecting for cloudflare

Reported by: meshr Owned by:
Priority: normal Milestone:
Component: General Version: 4.3
Severity: normal Keywords:
Cc: Focuses:

Description

My blog is behind cloudflare and if i use https to access it then it doesn't display properly because is_ssl() function doesn’t detect https. I added $_SERVER['HTTP_X_FORWARDED_PROTO'] variable check and it works now properly. Here is a fix for is_ssl() in my wp-includes/functions.php:

function is_ssl() {
	if ( isset($_SERVER['HTTPS']) ) {
		if ( 'off' !== 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)

cloudflare.diff (489 bytes ) - added by meshr 11 years ago.
diff from github

Download all attachments as: .zip

Change History (3)

#1 @atomicjack
11 years ago

You'll need to submit a .patch/.diff file for it to be considered for core. :)

Have a read over this handbook: http://make.wordpress.org/core/handbook/

Welcome to Trac!

@meshr
11 years ago

diff from github

#2 @johnbillion
11 years ago

  • Milestone Awaiting Review
  • Resolutionduplicate
  • Status newclosed

Duplicate of #31288.

Thanks for the report, meshr. This is something that comes up often, but is not something that will be fixed due to the nature of client-provided headers. See here for more info.

Note: See TracTickets for help on using tickets.