nginx:[emerg] 角度 15 中的 /etc/nginx/conf.d/default.conf:1 中不允許使用「worker_processes」指令?

nginx:[emerg] 角度 15 中的 /etc/nginx/conf.d/default.conf:1 中不允許使用「worker_processes」指令?

我面臨這個錯誤,

nginx: [emerg] /etc/nginx/conf.d/default.conf:1 中不允許使用「worker_processes」指令

泊塢視窗文件:

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 檔案:

更新設定檔伺服器{listen 80;伺服器名稱本地主機;

        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文件,而是您(或您的一個)網站的個人資料。

接受該指令的主設定檔worker_process位於/etc/nginx/nginx.conf.

您的httpevents指令也將無法在/etc/nginx/conf.d/default.conf.

預設的 nginx.conf 檔案已包含這些指令,並且工作進程設定為 auto:

worker_processes  auto;

從網站設定檔中刪除 http、events 和worker_processes,然後在主nginx.conf檔案中調整這些設定。

相關內容