Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker Nginx目录索引为/src/”等;在库伯内特斯是被禁止的_Docker_Nginx_Kubernetes - Fatal编程技术网

Docker Nginx目录索引为/src/”等;在库伯内特斯是被禁止的

Docker Nginx目录索引为/src/”等;在库伯内特斯是被禁止的,docker,nginx,kubernetes,Docker,Nginx,Kubernetes,在Kubernetes内设置Docker Nginx配置时,我得到一个“/src/”的目录索引被禁止错误。这是Kubernetes日志中的错误 /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

在Kubernetes内设置Docker Nginx配置时,我得到一个“/src/”的
目录索引被禁止
错误。这是Kubernetes日志中的错误

/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"
我的dockerfile为Angular应用程序提供nginx服务非常简单:

FROM nginx

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

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

COPY dist /src

RUN ls /src
我的nginx.conf文件包含:

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

Kubernetes部署正在使用码头映像。您认为我的错误可能在dockerfile、nginx.conf文件中,还是两者都有?

在dockerfile复制行中,您正在将conf.d复制到nginx文件夹中,请尝试更改该错误

FROM nginx

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

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

COPY dist /src

RUN ls /src

我通过将Angular
构建
输出路径
更改为
“dist”
而不是Angular安装配置的默认
“dist/my project”
解决了我的错误

"architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist", // was previously "dist/my-project"

谢谢我试过了,但没有纠正错误。