Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

438
Views
Docker Nginx directory index of "/src/" is forbidden in Kubernetes

I'm getting a directory index of "/src/" is forbidden error when setting up Docker Nginx configuration within Kubernetes. Here is the error from the Kubernetes logs.

/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 "/src/" is forbidden, client: 10.136.144.155, server: 0.0.0.0, request: "GET / HTTP/1.1", host: "10.42.3.4:80"
10.136.144.155 - - [11/Mar/2021:02:23:24 +0000] "GET / HTTP/1.1" 403 125 "-" "kube-probe/1.15"

My dockerfile to serve nginx for an Angular app is quite simple:

FROM nginx

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

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

COPY dist /src

RUN ls /src

My nginx.conf file contains:

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;
        }
    }
}

The Kubernetes deployment is using a Quay image. Do you think my error could be in the dockerfile, the nginx.conf file, or both?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

In Dockerfile copy line, you are copying conf.d to nginx folder, try to change that

FROM nginx

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

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

COPY dist /src

RUN ls /src
over 4 years ago · Santiago Trujillo Report

0

I solved my error by changing my Angular build outputPath to "dist" rather than the default "dist/my-project" that was configured with the Angular installation.

"architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist", // was previously "dist/my-project"
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!