I'm facing an infinite redirect loop issue with a WordPress site deployed on Google Kubernetes Engine (GKE) using the Bitnami WordPress Docker image. The problem occurs when I set a static page as the homepage directly from the WordPress admin interface. Notably, this issue doesn't arise when running the container locally. Everthing working well without 301 redirection. SSL termination is managed by the GKE Ingress using Google-managed SSL certificates.
Environment Details:
- Kubernetes on GKE
- WordPress served using the Bitnami Docker image, with Nginx as the web server within the containers
- HTTPS managed by GKE Ingress with managed certificates for SSL
- Redirection configured via WordPress admin interface to make /home the homepage
Issue: After configuring the static homepage (/home) from within WordPress, my site enters an infinite redirect loop when accessed. Disabling HTTPS redirection in FrontendConfig to troubleshoot did not resolve the issue, and the server eventually crashes with error 502.
ingress config
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: wordpress-ingress
annotations:
kubernetes.io/ingress.class: "gce"
networking.gke.io/managed-certificates: "my-ssl-cert"
spec:
rules:
- host: "mywordpresssite.com"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: wordpress-service
port:
number: 80
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert -f docker-compose.yml
kompose.version: 1.31.2 (a92241f79)
creationTimestamp: null
labels:
io.kompose.service: wordpress
name: wordpress
spec:
ports:
- name: http
port: 80
targetPort: 8080
# - name: https
# port: 443
# targetPort: 8443
selector:
io.kompose.service: wordpress
type: NodePort```
apiVersion: networking.gke.io/v1beta1 kind: FrontendConfig metadata: name: frontend-https-config spec: redirectToHttps: enabled: true # responseCodeName: PERMANENT_REDIRECT```
- Why does 301 redirect setting /home as a static homepage to root cause an infinite redirect loop in a GKE environment using the Bitnami image, but not locally?
- How should I adjust the setup to prevent this redirect loop while maintaining the static homepage configuration via WordPress?
- Are there specific considerations for Bitnami WordPress images on GKE when configuring site structure through WordPress admin, especially regarding SSL termination by the Ingress?
- I appreciate any insights or suggestions to debug and resolve this infinite redirect loop issue.
Setting up ENV variable WORDPRESS_ENABLE_REVERSE_PROXY to yes https://github.com/bitnami/containers/tree/main/bitnami/wordpress-nginx
adding :
if ( ! empty( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) {
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}
if ( ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
$_SERVER['HTTPS'] = 'on';
}