![nginx: [emerg] Angular 15 の /etc/nginx/conf.d/default.conf:1 では「worker_processes」ディレクティブは許可されませんか?](https://rvso.com/image/792433/nginx%3A%20%5Bemerg%5D%20Angular%2015%20%E3%81%AE%20%2Fetc%2Fnginx%2Fconf.d%2Fdefault.conf%3A1%20%E3%81%A7%E3%81%AF%E3%80%8Cworker_processes%E3%80%8D%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%86%E3%82%A3%E3%83%96%E3%81%AF%E8%A8%B1%E5%8F%AF%E3%81%95%E3%82%8C%E3%81%BE%E3%81%9B%E3%82%93%E3%81%8B%3F.png)
このエラーが発生しています。
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
ファイル内でそれらの設定を微調整します。