nginx: [emerg] Die Direktive „worker_processes“ ist hier in /etc/nginx/conf.d/default.conf:1 in Angular 15 nicht zulässig?

nginx: [emerg] Die Direktive „worker_processes“ ist hier in /etc/nginx/conf.d/default.conf:1 in Angular 15 nicht zulässig?

Ich stehe vor diesem Fehler,

nginx: [emerg] Die Direktive „worker_processes“ ist hier in /etc/nginx/conf.d/default.conf:1 nicht zulässig.

Docker-Datei:

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;"]

Dies ist meine nginx.conf-Datei:

Aktualisierte Konfigurationsdatei 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";
        }
    }

Ursprüngliche 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";
        }
    }
}

kann mir jemand helfen, wo ich falsch liege?

Antwort1

Dies ist tatsächlich nicht Ihre main nginx.confDatei, sondern eine Konfigurationsdatei für Ihre (oder eine Ihrer) Websites.

Die Hauptkonfigurationsdatei, die die worker_processAnweisung akzeptiert, befindet sich unter /etc/nginx/nginx.conf.

Ihre httpund eventsAnweisungen funktionieren auch unter nicht /etc/nginx/conf.d/default.conf.

Die Standarddatei nginx.conf enthält bereits diese Anweisungen und die Arbeitsprozesse sind auf „auto“ eingestellt:

worker_processes  auto;

Löschen Sie http, Ereignisse und Arbeitsprozesse aus Ihrer Website-Konfigurationsdatei und optimieren Sie diese Einstellungen in Ihrer Hauptdatei nginx.conf.

verwandte Informationen