Make WordPress Core

Opened 9 years ago

Closed 9 years ago

#33730 closed defect (bug) (duplicate)

ssl is not detecting for cloudflare

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

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 9 years ago.
diff from github

Download all attachments as: .zip

Change History (3)

#1 @atomicjack
9 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
9 years ago

diff from github

#2 @johnbillion
9 years ago

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

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.