Problem statement:
At the time of this publication the default ingress HTTP LoadBalancer on Google Kubernetes Engine does not support http-to-https redirection. Furthermore the Kubernetes based configmap of the Click to Deploy solution requires http requests (no https!) to localhost in order to install WordPress (for example).
Therefore a solution is required, which redirects requests from http to https, but also excludes healthchecks, https requests as well as requests to localhost from http-to-https redirection.
Solution:
This solution describes how to enable http-to-https redirection on the Google Kubernetes Engine (GKE) for the Google Click to Deploy Kubernetes WordPress App. For this solution just the Apache web server and the default ingress HTTP LoadBalancer on GKE, but no Nginx ingress controller is required.
Extend the Kubernetes ConfigMap for .htaccess as follows:
.htaccess: | <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{QUERY_STRING} !healthcheck RewriteCond %{HTTP_HOST} !localhost RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] </IfModule>
Change the readinessProbe and livenessProbe path with a custom healthcheck path as follows:
readinessProbe: httpGet: path: /?healthcheck port: 80 scheme: HTTP initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 successThreshold: 2 failureThreshold: 5 livenessProbe: httpGet: path: /?healthcheck port: 80 scheme: HTTP initialDelaySeconds: 120
Need further support or Kubernetes Consulting?
Please checkout our Consulting hours.
You don’t want to go into technical details anymore?
Check out the Blue Antoinette Commerce Cloud, which is built on and abstracts away the complexities of Kubernetes.
–