nginx ingress FCGI + wordpress:fpm-alpine. 302 redirect infinite loop

12/27/2019

So FGCI came out this year. Would like to test out some WordPress but I hear it has some rewrite rules that need to be followed. Can't quite get the nginx.ingress.kubernetes.io/rewrite-target or nginx.ingress.kubernetes.io/configuration-snippet correct. Can anyone help me translate this ingress definition so I can work with just nginx-ingress and wordpress fpm?

apiVersion: v1
kind: ConfigMap
metadata:
  name: word-cm
data:
  SCRIPT_FILENAME: "/var/www/html/index.php"

---

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/backend-protocol: "FCGI"
    nginx.ingress.kubernetes.io/fastcgi-index: "index.php"
    nginx.ingress.kubernetes.io/fastcgi-params-configmap: "word-cm"
    nginx.ingress.kubernetes.io/configuration-snippet: |
        location / {
          $uri $uri/ /index.php?$args;
        } 
  name: word
spec:
  rules:
  - host: word.press.site
    http:
      paths:
      - backend:
          serviceName: word
          servicePort: fastcgi

Currently getting this when trying to base it off of https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/

-------------------------------------------------------------------------------
W1227 09:49:02.610057       6 queue.go:130] requeuing mcsh/word, err
-------------------------------------------------------------------------------
Error: exit status 1
2019/12/27 09:49:02 [emerg] 807#807: unknown directive "$uri" in /tmp/nginx-cfg091168912:668
nginx: [emerg] unknown directive "$uri" in /tmp/nginx-cfg091168912:668
nginx: configuration file /tmp/nginx-cfg091168912 test failed

-------------------------------------------------------------------------------

Without it, I get 302s to install page infinitely.

-- quantomworks
kubernetes
nginx
nginx-ingress
wordpress

0 Answers