GoogleCloudPlatform/click-to-deploy

Wordpress-ha fails when using PATHINFO (a.k.a 'almost pretty') permalinks

chateauvieux opened this issue · 0 comments

Category:

Virtual machines

Type:

  • Bug
  • Feature Request
  • Process

When activating PATHINFO (a.k.a 'almost pretty') permalinks, the GCP healthcheck fails as WP returns a 301 (instead of a 200) HTTP code due to the permalink URL rewrite. Soon after that, the VM gets replaced by the instance group manager, and the same issue happens over and over. As a consequence, the load balancer endlessly returns a 502 server error to the client.

To work around this isse, one can change the healthCheck rules in admin_node.jinja and content_node.jinja by
requestPath: /?healthCheck=true
and insert the following rewrite rule in the beginning of the .htaccess file:

RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{QUERY_STRING} !.*healthCheck=true.* RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

(many thanks to the authour of this blog which put me in the right direction to find a fix for this)
https://code.haleby.se/2015/12/11/redirect-http-to-https-in-wordpress-running-behind-a-google-http-load-balancer/