Nginx Ingress Controller - 404 not found

Hi all, we’re new to Kubernetes we’re trying to build a nginx-php app, and with a persistent volume claim. We’re able to see the phpinfo from an initcontainer, however when tried accessing from our nginx ingress it’s giving a 404 not found. How can we edit the nginx config and add a running vhost? Thanks!

Here are the details for our configs:

svc:

apiVersion: v1
kind: Service
metadata:
  name: php
  labels:
    tier: backend
spec:
  selector:
    app: php
    tier: backend
  ports:
  - protocol: TCP
    port: 9000

pv:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: dir
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi

configmap:

apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config
  labels:
    tier: backend
data:
  config : |
    server {
      index index.php index.html;
      error_log  /var/log/nginx/error.log;
      access_log /var/log/nginx/access.log;
      root /dir;

      location / {
          try_files $uri $uri/ /index.php?$query_string;
      }

      location ~ \.php$ {
          try_files $uri =404;
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
          fastcgi_pass php:9000;
          fastcgi_index index.php;
          include fastcgi_params;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_param PATH_INFO $fastcgi_path_info;
        }
    }

php deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: php
  labels:
    tier: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: php
      tier: backend
  template:
    metadata:
      labels:
        app: php
        tier: backend
    spec:
      volumes:
      - name: dir
        persistentVolumeClaim:
          claimName: dir
      containers:
      - name: php
        image: php:7.4-fpm
        volumeMounts:
        - name: dir
          mountPath: /dir
      initContainers:
      - name: install
        image: busybox
        volumeMounts:
        - name: dir
          mountPath: /dir
        command:
        - wget
        - "-O"
        - "/dir/index.php"
        - https://raw.githubusercontent.com/do-community/php-kubernetes/master/index.php

nginx deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    tier: backend
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
      tier: backend
  template:
    metadata:
      labels:
        app: nginx
        tier: backend
    spec:
      volumes:
      - name: dir
        persistentVolumeClaim:
          claimName: dir
      - name: config
        configMap:
          name: nginx-config
          items:
          - key: config
            path: site.conf
      containers:
      - name: nginx
        image: nginx:latest
        ports:
        - containerPort: 80
        volumeMounts:
        - name: dir
          mountPath: /dir
        - name: config
          mountPath: /etc/nginx/conf.d

nginx ingress

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: nginx-ingress-vhost
  labels:
    tier: backend

spec:
  rules:
  - host: nginx-php.app.com
    http:
      paths:
      - pathType: Prefix
        path: /vhost1
        backend:
          service:
            name: nginx
            port:
              number: 80
      - pathType: Prefix
        path: /vhost2
        backend:
          service:
            name: nginx
            port:
              number: 80

Cluster information:

Kubernetes version: 1.21
Cloud being used: DigitalOcean
Installation method: manifest
Host OS: ubuntu
CNI and version:
CRI and version:

You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.