Make WordPress Core

Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#43698 closed defect (bug) (invalid)

4.9.5 broke site behind load balancer, forwards to localhost

Reported by: ssuess's profile ssuess Owned by:
Milestone: Priority: normal
Severity: major Version: 4.9.5
Component: General Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

I have 2 wordpress web servers behind a load balancer. When updating from 4.9.4 to 4.9.5, these sites broke if accessed from the main domain (but continue to be accessible if I use their alternate addresses which is obvi not possible for our end users). Instead of the site loading by going to the main domain https://example.com, everyone who accesses the domain is instead directed to https://localhost.

As I said, if someone accessed https://wp1.example.com or https://wp2.example.com (the direct addresses), the sites work. For now, I have reverted to 4.9.4 which fixes the problem, but I would like to figure out a long term fix. Any suggestions?

FYI inside my wp-config files I am using these directives:

define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);

Which I need in place to be able to address the machines directly as well as having them work with the main domain via the load balancer.

I think I found the changeset responsible for this behaviour: [42894] but still have no workable fix.

Change History (7)

#1 @ssuess
6 years ago

  • Severity changed from normal to major

#2 @ssuess
6 years ago

I was able to work around this and update by changing my wp-config directives to:

define('WP_SITEURL', 'https://' . $_SERVER['SERVER_NAME']);
define('WP_HOME', 'https://' . $_SERVER['SERVER_NAME']);

And also adding a param to my nginx conf to properly account for variable server names:

fastcgi_param SERVER_NAME $host;

without both of the above, my particular setup would not work properly.

#3 @ssuess
6 years ago

spoke too soon, all kinds of badly formatted page if connecting to load balancer, despite ssl insecure content fixer. Reverted to 4.9.4 and undid changes and problem went away.

#4 @ssuess
6 years ago

Still super broken....

This ticket was mentioned in Slack in #core by noisysocks. View the logs.


4 years ago

#6 @peterwilsoncc
4 years ago

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

This was discussed in a triage session today.

As load balancers forward SSL headers and host headers in a variety of ways there's not much WordPress can do that's going to work universally.

The common solution is to hard code the values of $_SERVER['HTTPS'], WP_SITEURL and WP_HOME to match what is expected at the load balancer.

I saw you found the support forums for this, they are the best spot to ask so I am going to close this off as invalid, which is trac's unfriendly term to indicate this is best asked in support.

#7 @SergeyBiryukov
4 years ago

  • Description modified (diff)
Note: See TracTickets for help on using tickets.