title: NGINX Ingress + Wordpress-fpm = ERR_TOO_MANY_REDIRECTS
body: <p>I've been searching and looking everywhere on the internet and on these forms for days to help understand how to properly setup <strong>NGINX Ingress with Wordpress-fpm</strong>. I'm rather new to Kubernetes and all so I've been working on setting this up to help me learn it all.</p>
  <p>I can get it to work using the image of Wordpress that has Apache included but I rather use NGINX over Apache so this is the reason I'm trying to get it to work.</p>
  <p>It seems that once all manifests are applied I visit localhost and I see this, ERR_TOO_MANY_REDIRECTS. I'm guessing that Wordpress can't get the header of <strong>X-Forwarded-Proto</strong> that it's looking for in the wp-config.php to let it know it's behind a reverse proxy of sorts.</p>
  <p>Below are the manifest that I'm using:</p>
  <p><em><strong>wordpress.yml</strong></em></p>
  <pre><code>apiVersion: v1
  kind: Service
  metadata:
    name: wordpress-service
    namespace: wordpress
  spec:
    selector:
      app: wordpress-fpm
    type: ClusterIP
    ports:
    - name: https
      port: 443
      targetPort: 9000
      protocol: TCP
    - name: http
      port: 80
      targetPort: 9000
      protocol: TCP
  ---
  apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: wp-pv-claim
    namespace: wordpress
    labels:
      app: wordpress-fpm
  spec:
    accessModes:
      - ReadWriteOnce
    resources:
      requests:
        storage: 20Gi
  ---
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: wordpress-fpm
    namespace: wordpress
    labels:
      app: wordpress-fpm
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: wordpress-fpm
    template:
      metadata:
        labels:
          app: wordpress-fpm
      spec:
        containers:
        - name: wordpress-fpm
          image: wordpress:5.5-php7.4-fpm-alpine
          env:
          - name: WORDPRESS_DB_HOST
            value: maria-db-service
          - name: WORDPRESS_DB_NAME
            valueFrom:
              secretKeyRef:
                name: maria-db-secret
                key: db-name
          - name: WORDPRESS_DB_USER
            valueFrom:
              secretKeyRef:
                name: maria-db-secret
                key: db-user
          - name: WORDPRESS_DB_PASSWORD
            valueFrom:
              secretKeyRef:
                name: maria-db-secret
                key: db-user-password
          volumeMounts:
          - name: wordpress-persistent-storage
            mountPath: /var/www/html
        volumes:
        - name: wordpress-persistent-storage
          persistentVolumeClaim:
            claimName: wp-pv-claim
  </code></pre>
  <p><em><strong>ingress.yml</strong></em></p>
  <pre><code>apiVersion: v1
  kind: ConfigMap
  metadata:
    name: nginx-config
    namespace: wordpress
  data:
    SCRIPT_FILENAME: &quot;/var/www/html/index.php&quot;
    FASTCGI_PASS : &quot;wordpress-fpm:9000&quot;
    fastcgi_pass: &quot;wordpress-fpm:9000&quot;
  ---
  apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    name: nginx
    namespace: wordpress
    annotations:
      kubernetes.io/ingress.class: &quot;nginx&quot;
      nginx.ingress.kubernetes.io/backend-protocol: &quot;FCGI&quot;
      nginx.ingress.kubernetes.io/fastcgi-index: index.php
      nginx.ingress.kubernetes.io/fastcgi-params-configmap: nginx-config
      ingress.kubernetes.io/rewrite-target: /$1
  spec:
    tls:
    - hosts:
        - localhost
      secretName: testsecret-tls
    rules:
      - host: localhost
        http:
          paths:
          - pathType: Prefix
            path: &quot;/&quot;
            backend:
              service:
                name: wordpress-service
                port:
                  name: http
  </code></pre>