<p>I'm getting a <code>directory index of &quot;/src/&quot; is forbidden</code> error when setting up Docker Nginx configuration within Kubernetes. Here is the error from the Kubernetes logs.</p>
<pre><code>/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2021/03/11 02:23:24 [error] 23#23: *1 directory index of &quot;/src/&quot; is forbidden, client: 10.136.144.155, server: 0.0.0.0, request: &quot;GET / HTTP/1.1&quot;, host: &quot;10.42.3.4:80&quot;
10.136.144.155 - - [11/Mar/2021:02:23:24 +0000] &quot;GET / HTTP/1.1&quot; 403 125 &quot;-&quot; &quot;kube-probe/1.15&quot;
</code></pre>
<p>My dockerfile to serve nginx for an Angular app is quite simple:</p>
<pre><code>FROM nginx

RUN rm /etc/nginx/conf.d/default.conf

COPY ./nginx/conf.d /etc/nginx/

COPY dist /src

RUN ls /src
</code></pre>
<p>My nginx.conf file contains:</p>
<pre><code>worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name 0.0.0.0;
        root   /src;

        charset utf-8;
        include h5bp/basic.conf; # eg https://github.com/h5bp/server-configs-nginx
        include modules/gzip.conf;

        location =/index.html {
            include modules/cors.conf;
        }

        location / {
            try_files $uri$args $uri$args/ /index.html;
        }
    }
}
</code></pre>
<p>The Kubernetes deployment is using a Quay image. Do you think my error could be in the dockerfile, the nginx.conf file, or both?</p>

<p>In Dockerfile copy line, you are copying conf.d to nginx folder, try to change that</p>
<pre><code>FROM nginx

RUN rm /etc/nginx/conf.d/default.conf

COPY ./nginx/conf.d /etc/nginx/conf.d

COPY dist /src

RUN ls /src
</code></pre>
