![nginx:[emerg] 角度 15 中的 /etc/nginx/conf.d/default.conf:1 中不允許使用「worker_processes」指令?](https://rvso.com/image/792433/nginx%EF%BC%9A%5Bemerg%5D%20%E8%A7%92%E5%BA%A6%2015%20%E4%B8%AD%E7%9A%84%20%2Fetc%2Fnginx%2Fconf.d%2Fdefault.conf%3A1%20%E4%B8%AD%E4%B8%8D%E5%85%81%E8%A8%B1%E4%BD%BF%E7%94%A8%E3%80%8Cworker_processes%E3%80%8D%E6%8C%87%E4%BB%A4%EF%BC%9F.png)
我面臨這個錯誤,
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
.
您的http
和events
指令也將無法在/etc/nginx/conf.d/default.conf
.
預設的 nginx.conf 檔案已包含這些指令,並且工作進程設定為 auto:
worker_processes auto;
從網站設定檔中刪除 http、events 和worker_processes,然後在主nginx.conf
檔案中調整這些設定。