nginx: [emerg] Angular 15 の /etc/nginx/conf.d/default.conf:1 では「worker_processes」ディレクティブは許可されませんか?

nginx: [emerg] Angular 15 の /etc/nginx/conf.d/default.conf:1 では「worker_processes」ディレクティブは許可されませんか?

このエラーが発生しています。

nginx: [emerg] /etc/nginx/conf.d/default.conf:1 では「worker_processes」ディレクティブは許可されていません

Docker ファイル:

FROM artifactorycloud.ual.com/v-docker/node:16 AS builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build --configuration=development
FROM artifactorycloud.ual.com/v-docker/nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy the nginx conf that we created to the container
COPY ./nginx.conf  /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

これは私の nginx.conf ファイルです:

更新された設定ファイル server { listen 80; server_name localhost;

        root   /usr/share/nginx/html;
        index  index.html index.htm;
        include /etc/nginx/mime.types;

        gzip on;
        gzip_min_length 1000;
        gzip_proxied expired no-cache no-store private auth;
        gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        location / {
            try_files $uri $uri/ /index.html;
        }

        location /ui/health {
            access_log off;
            add_header 'Content-Type' 'text/plain';
            return 200 "Healthy\n";
        }
    }

オリジナルの nginx.conf

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    server {
        listen 80;
        server_name  localhost;

        root   /usr/share/nginx/html;
        index  index.html index.htm;
        include /etc/nginx/mime.types;

        gzip on;
        gzip_min_length 1000;
        gzip_proxied expired no-cache no-store private auth;
        gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

        location / {
            try_files $uri $uri/ /index.html;
        }

        location /ui/health {
            access_log off;
            add_header 'Content-Type' 'text/plain';
            return 200 "Healthy\n";
        }
    }
}

私が間違っているところについて誰か助けてくれませんか?

答え1

これは実際にはあなたのmain nginx.confファイルではなく、あなたの(またはあなたのウェブサイトの 1 つ)ウェブサイトの構成ファイルです。

ディレクティブを受け入れるメインの設定ファイルworker_processは にあります/etc/nginx/nginx.conf

httpおよびディレクティブもeventsでは動作しません/etc/nginx/conf.d/default.conf

デフォルトの nginx.conf ファイルにはすでにこれらのディレクティブが含まれており、ワーカー プロセスは自動に設定されています。

worker_processes  auto;

ウェブサイトの設定ファイルから http、events、worker_processes を削除し、メインnginx.confファイル内でそれらの設定を微調整します。

関連情報