Problem with WordPress using HTTPS

I have a WordPress site on a Windows server using IIS, that is using an HTTPS address served from our load balancer. When the site was using just http and no load balancer, it worked fine. Now, none of my stylesheets or other assets are loading on the front end (they say http instead of https), and when I try to login to the WordPress dashboard (wp-admin), I get an error that says the site "redirected too many times".

I have updated the site and WordPress URLs to HTTPS in my WP database. And, I have tried adding various code to my wp-config.php file, along with some rewrite rules to my web.config file but nothing seems to work.

Here are the various lines of code I have tried in my wp-config.php file:

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';

Open in new window


if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'){
	 $_SERVER['HTTPS']='on';
	 $_SERVER['SERVER_PORT'] = 443;
}

Open in new window


define('FORCE_SSL_ADMIN', true);

Open in new window

define('FORCE_SSL_LOGIN', true);

Open in new window


I cannot figure out why the dashboard login won't load, and the front end assets only load with http??
kenjpeteAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin MillerCTOCommented:
You may have two problems...

Can you isolate to one? e.g.

-  let HTTP: pass through the load balancer to HTTP on your WordPress site?

Then you can confirm pass through with HTTP works with WordPress.

After that you can may one change at a time for HTTPS/SSL, like terminate SSL on the load balancer and use HTTP to WordPress.
0
kenjpeteAuthor Commented:
I'm not sure I fully understand what you are suggesting, but I don't have access to the load balancer on our network. Is there anything I can do from the WordPress side to isolate the problem?
0
Martin MillerCTOCommented:
Validate Internal network to Wordpress, and bypass NAT or SSL termination from Load Balancer.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kenjpeteAuthor Commented:
Looks like things are working as they should now. Your solution of validating traffic from our load balancer to our WordPress server turned out to be the right place to look.

As it turns out the internal traffic from our load balancer to our WP server was going over port 443 but it was http, not https. So the script I added to wp-config.php wouldn't work because the forwarded protocol from our load balancer was http, not https, which is why my original IF/THEN statement never tested as true. See code below:

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';

Open in new window


Once I changed it to the code below it worked like a charm:

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== true)
$_SERVER['HTTPS']='on';

Open in new window


thanks!
0
Martin MillerCTOCommented:
Awesome, glad you have this resolved!

Martin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.