<p>I need some help on nginx-php application deployment. I am totally new into kubernetes trying to run a php code. I am running this on minikube. </p>

<p>This is my Dockerfile file</p>

<pre><code>FROM php:7.2-fpm
RUN mkdir /app
COPY hello.php /app
</code></pre>

<p>This is my web.yaml file which includes Deployment and Service</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: web-deployment
  labels:
    app: web-server
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: web-server
    spec:
      volumes:
    # Create the shared files volume to be used in both pods
        - name: shared-files
          emptyDir: {}


        - name: nginx-config-volume
          configMap:
            name: nginx-config
      containers:
      - name: nginx
        image: nginx:latest
        ports:
          - containerPort: 80
        volumeMounts:
        - name: shared-files
          mountPath: /var/www/html
        - name: nginx-config-volume
          mountPath: /etc/nginx/nginx.conf
          subPath: nginx.conf
      - name: php-fpm
        image: my-php-app:1.0.0
        ports:
          - containerPort: 80
        volumeMounts:
        - name: shared-files
          mountPath: /var/www/html
        lifecycle:
          postStart:
            exec:
              command: ["/bin/sh", "-c", "cp -r /app/. /var/www/html"]
---
apiVersion: v1
kind: Service
metadata:
  name: web-service
  labels:
    app: web-server
spec:
  ports:
  - port: 80
  type: NodePort
  selector:
    app: web-server
</code></pre>

<p>This is my config.yaml file for nginx ConfigMap</p>

<pre><code>kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-config
data:
  nginx.conf: |
    events {
    }
    http {
      server {
        listen 80 default_server;
        listen [::]:80 default_server;

        # Set nginx to serve files from the shared volume!
        root /var/www/html;
        server_name _;
        location / {
          try_files $uri $uri/ =404;
        }
        location ~ \.php$ {
          include fastcgi_params;
          fastcgi_param REQUEST_METHOD $request_method;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          fastcgi_pass 127.0.0.1:9000;
        }
      }
    }
</code></pre>

<p>I have created the deployment, services and configmap using</p>

<pre><code>kubectl create -f web.yaml

kubectl create -f configmap.yaml
</code></pre>

<p>After I get the ip and port through</p>

<pre><code>minikube service web-service --url
</code></pre>

<p>I get an ip like this <a href="http://192.168.99.100:31170" rel="nofollow noreferrer">http://192.168.99.100:31170</a>
When I browse this Ip, I get a response like <strong>nginx 403 forbidden</strong></p>

<p>What did I do wrong here?</p>

<p>Seems like nginx unable to access default page.</p>

<p>Either add <code>index hello.php</code> to nginx configuration </p>

<pre><code> location / {
          index hello.php;
          try_files $uri $uri/ =404;
        }
</code></pre>

<p>Or, 
access your application via 
absolute URL <code>http://192.168.99.100:31170/hello.php</code> </p>
